Custom Scheduler Runtime
The easiest way to write your own scheduler is by referencing the one already created.
The core of it is the following:
import { getScheduledTasks, runScheduledTask } from '@pikku/core/scheduler'
const run = async (singletonServices: SingletonServices, name: string) => {
const { scheduledTasks } = getScheduleTasks()
await runScheduledTask({
singletonServices: this.singletonServices,
name,
})
}
info
In the case of serverless, this is all that's actually needed, since the runtime is responsible for invoking the method.
Writing a Task Scheduler for servers
The rest of it is integrating it with your prefered cron library. The following is the implementation of the PikkuTaskScheduler
provided for non-serverless invocation.
PikkuTaskScheduler
loading...