job-handler
v0.0.8
Published
This lib allows you to handle async jobs in a micro-services architecture, using RabbitMq and MongoDB.
Downloads
2
Readme
job-handler
This lib allows you to handle async jobs in a micro-services architecture, using RabbitMq and MongoDB.
Usage
const jobHandler = await JobHandler.create({
rabbitMqUrl: 'amqp://user:password@address:5672',
jobApiUrl: 'http://my-job-api-url',
});
await jobHandler.addHandler('job-name', async (job) => {
// You job handler here
});
await jobHandler.addHandler('other-job-name', async (job) => {
// You job handler here
});
JobHandler parameters :
- rabbitMqUrl (string): Connection URL for your RabbitMQ instance.
- jobApiUrl (string): URL of the Job API to get jobs and update their status.
- maxParallelJobs (number, default = 0): Maximum number of jobs which can be processed simultaneously (global to all handlers you add)
- logger (Logger, default = no logs): You can provide an implementation of the interface Logger to display logs of the JobHandler