io.registerInterval()
io.registerInterval()
allows you to register a DynamicSchedule that will trigger any jobs it's attached to on a regular interval.
This has been deprecated in favor of DynamicSchedule.register
Parameters
Should be a stable and unique key inside the run()
. See
resumability for more information.
A DynamicSchedule that will trigger any Jobs it’s attached to on a regular interval.
A unique id for the interval. This is used to identify and unregister the interval later.
An object containing options about the interval.
The number of seconds for the interval. Min = 60, Max = 2_592_000 (30 days)
Returns
A Promise that resolves to an object with the following fields:
A unique id for the interval. This is used to identify and unregister the interval later.
Any additional metadata about the interval.
This will be used by the Trigger.dev Connect feature, which is coming soon.
The type of schedule. This will always be “interval”.
An object containing options about the interval.
The number of seconds for the interval. Min = 60, Max = 2_592_000 (30 days)
Any additional metadata about the interval.
client.defineJob({
id: "my-job",
name: "My job",
version: "0.1.1",
trigger: eventTrigger({
name: "dynamic.interval",
schema: z.object({
id: z.string(),
seconds: z.number().int().positive(),
}),
}),
run: async (payload, io, ctx) => {
//registers a DynamicSchedule with an interval
await io.registerInterval("📆", dynamicSchedule, payload.id, {
seconds: payload.seconds,
});
},
});
Was this page helpful?
client.defineJob({
id: "my-job",
name: "My job",
version: "0.1.1",
trigger: eventTrigger({
name: "dynamic.interval",
schema: z.object({
id: z.string(),
seconds: z.number().int().positive(),
}),
}),
run: async (payload, io, ctx) => {
//registers a DynamicSchedule with an interval
await io.registerInterval("📆", dynamicSchedule, payload.id, {
seconds: payload.seconds,
});
},
});