Scheduling Tasks
Concept
Scheduling task is a simple concept:
Run a job at
${date}with ${payload}`
But since we want to make tellia horitonzally scallable we must ensure two or more instance of a service will run.
That means if you're scheduling any mutating operation, such as:
calling a clientupdate in dbcall to apisapi callanything scheduled
We need to make sure the execution happens without concurrency.
Solution
This can be solved many ways, and it often includes a queue system (RabbitMQ, Google Pubsub, BullMQ, Redis Streams)
Tellia currently uses the native BullMQ job scheduler to schedule jobs.
typescript
await this.queue.upsertJobScheduler(
'my-bootstrap-job-v1', // Unique ID prevents duplicates
{
pattern: 'some-cron-pattern', // Run as soon as possible
limit: 1, // Only execute once, then auto-remove
},
{ data: MyJobSchema.parse({}) },
);Active jobs
Active jobs can be seen on bullboard, see URLS
What you see: 
- The card title is the queue name.
- Purple jobs are scheduled jobs enqueued
Then, you can click on a queue and click the DELAYED tab.
- Data tab shows the job's data
- In Options you can see when the job will be triggered
