Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This enables StarbaseDB instances to be able to declare hooks in the
/src/index.ts
file to execute custom code at defined crontab intervals. By default Durable Objects can support 1 Alarm at a time (and Workers can support 3 cron jobs) but we need the ability to expand it so any number of events can signup to execute code at any interval. See below example for implementation.Currently there is a hardcoded limit of supporting 10 simultaneous events to trigger at any given interval which can easily be updated by adding more WHEN cases to the query. This was a technical decision for the moment to prevent accidental setups of recursively added calls but can easily be updated to support
N
events at any time.Tasks
tmp_cron_tasks
tableVerify
Each task should have an entry in the
tmp_cron_tasks
table of your StarbaseDB instance. An example row might look like:Then your code in your
/src/index.ts
would implement the plugin setup like below:Before
After