0.1.6 • Published 10 months ago

jobify v0.1.6

Weekly downloads
1
License
-
Repository
-
Last release
10 months ago

jobify

npm JSR JSR Score

Type-safe and much simpler wrapper for the BullMQ library.

!WARNING This project is in the MVP state and the API may still change a lot. At the moment, the project fits the requirements of the project rather than general purpose

Usage

import { initJobify } from "jobify";
import IORedis from "ioredis";

const redis = new IORedis({
    maxRetriesPerRequest: null,
});

const defineJob = initJobify(redis);

const job1 = defineJob("some", {
    queue: {
        defaultJobOptions: {
            delay: 100,
        },
    },
})
    .input<{ date: string }>()
    // WORKER OPTIONS
    .options({
        limiter: {
            max: 10,
            duration: 1000,
        },
    })
    .action(async (job) => {
        console.log("running", job.data.date);
        //       ^?
    });

await job1.add(
    "some",
    { date: new Date().toISOString() },
    {
        delay: 5000,
    }
);

const job2 = await defineJob("some-cron")
    .input<{ date: string }>()
    .options({
        limiter: {
            max: 10,
            duration: 1000,
        },
    })
    .action(async (job) => {
        console.log("running", job.data.date);
        //       ^?
    })
    // it will run every minute and will not be duplicated during reboots.
    .repeatable(
        { date: new Date().toISOString() },
        {
            pattern: "* * * * *",
        }
    );

TODO:

  • maybe pg-boss adapter?
  • hooks?
  • make job title optional?
  • guide with bull-board and some improves for usage
0.1.2

10 months ago

0.1.1

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.0

11 months ago

0.0.2

11 months ago

0.0.1

12 months ago

1.0.0

11 years ago