DynamicSchedule
DynamicSchedule: Overview
DynamicSchedule
allows you to define a scheduled trigger that can be configured dynamically at runtime.
Sometimes you want to create a Job but define multiple different schedules that will Trigger it at runtime.
Constructor
DynamicSchedule()
Creates a new DynamicSchedule.
Instance methods
register()
Use this method to register a new schedule with the DynamicSchedule.
unregister()
Use this method to unregister a schedule from the DynamicSchedule, using the id you used when registering it.
Example use cases:
You want your users to be able to define their own schedule
- Create a
DynamicSchedule
. - Create a Job that will be triggered by the
DynamicSchedule
. - Anywhere in your codebase you can now call
yourDynamicSchedule.register
to add a new schedule. You should use your user’s userId when registering. - When the Job runs you can check the
context.source.id
to see which user triggered it.
Was this page helpful?