8000 GitHub - papra-hq/cadence-mq: Yet another job scheduling library for Node.js
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

papra-hq/cadence-mq

Repository files navigation

Header banner

Cadence MQ - Job scheduling library

Cadence MQ is a job scheduling library for Node.js. It is designed to be easy to use, flexible, and scalable.

Note

This is a work in progress, anything can change at any time.

Features

  • Job scheduling
  • Retry mechanism
  • Job status tracking
  • UI for monitoring and managing jobs
  • Unique key for jobs
  • Drivers for different backends
    • SQLite/LibSQL (in-memory, remote server or file-based)
    • Native in-memory
    • Redis
    • MongoDB

Why another job scheduling library?

There are many job scheduling libraries of quality, but most of them are tied to a specific backend, like BullMQ with Redis or Agenda with MongoDB. Cadence MQ is designed to be backend agnostic, and can be used with different backends, the motivation is to provide a simple simple for self-hostable applications but being able to scale horizontally in production environments.

This as been initially created for Papra, a self-hostable minimalistic document management platform, as we didn't want the self-hosters to have to setup a Redis.

Getting started

Basic example using LibSQL/SQLite as backend:

# using pnpm
pnpm install @cadence-mq/core @cadence-mq/driver-libsql

# using bun
bun add @cadence-mq/core @cadence-mq/driver-libsql

# using npm
npm install @cadence-mq/core @cadence-mq/driver-libsql

# using yarn
yarn add @cadence-mq/core @cadence-mq/driver-libsql
import { createQueue } from '@cadence-mq/core';
import { createLibSqlDriver, runMigrations } from '@cadence-mq/driver-libsql';
import { createClient } from '@libsql/client';

const client = createClient({ url: 'file:./cadence-mq.db' });
const queue = createQueue({ driver: createLibSqlDriver({ client }) });

queue.registerTask({
  name: 'send-welcome-email',
  handler: async ({ data }) => {
    console.log('Sending welcome email to', (data as { email: string }).email);
  },
});

queue.startWorker({ workerId: '1' });

await queue.scheduleJob({
  taskName: 'send-welcome-email',
  data: { email: 'test@test.com' },
});

Examples

Contributing

Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines on how to get started, report issues, and submit pull requests.

Credits

This project is crafted with ❤️ by Corentin Thomasset. If you find this project helpful, please consider supporting my work.

Acknowledgements

Cadence MQ is inspired by some great projects:

Abou 55C9 t

Yet another job scheduling library for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0