Skip to content

Bootstrap Jobs

Concept

Scheduling task is a simple concept:

Run this task once

But since we want to make tellia horitonzally scallable we must ensure this task run only once.

There are many solutions to this, some involve scripts deployments. The solution currently implemented by Tellia is to leverage the native BullMQ job scheduler to schedule jobs.

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
  {
    immediately: true, // Run as soon as possible
    limit: 1, // Only execute once, then auto-remove
  },
  { data: MyJobSchema.parse({}) },
);

You might want to track the version of the initialization you want to apply, if input changed and initialization is required. Or if you're developping a migration script that is not idempotent.

Active jobs

Active jobs can be seen on bullboard, see URLS

What you see: alt text

  • 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

alt text