Have ideas to improve npm?Join in the discussion! »

@art-of-coding/routed-worker

0.0.6 • Public • Published

Routed Worker for bullmq

Worker extension for bullmq.

This worker allows you to register processors for specific job names within the queue. The example shows how this package is used.

bullmq is a peer dependency, you'll need to install it yourself.

Install

npm i @art-of-coding/routed-worker bullmq [--save]

Example

import RoutedWorker, {
    Job
} from './index'
 
// create a new routed worker with the queue name 'Example'
const worker = new RoutedWorker('Example')
 
// Interface for job data
interface JobData {
    name: string,
    age: number
}
 
// Add a route, this is the job name (in this case, 'Greeting')
worker.on('Greeting', async (job: Job<JobData>) => {
    // Do something and return a result
    return `Hello, ${job.data.name}!`
})
 
// start the worker (required!)
worker.start()

License

Copyright 2020 Art of Coding.

This software is licensed under the MIT License.

Keywords

Install

npm i @art-of-coding/routed-worker

DownloadsWeekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

4.47 kB

Total Files

5

Last publish

Collaborators

  • avatar