Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juandl/moleculer-queues
Redis-based queue for moleculer using Bull
https://github.com/juandl/moleculer-queues
Last synced: 14 days ago
JSON representation
Redis-based queue for moleculer using Bull
- Host: GitHub
- URL: https://github.com/juandl/moleculer-queues
- Owner: juandl
- Created: 2022-03-15T11:07:24.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-19T18:27:51.000Z (6 months ago)
- Last Synced: 2024-10-03T06:53:53.971Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 153 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
![Moleculer logo](http://moleculer.services/images/banner.png)
# moleculer-queues [![NPM version](https://img.shields.io/npm/v/moleculer-queues.svg)](https://www.npmjs.com/package/moleculer-queues)
Redis-based queue for moleculerjs using [Bull](https://github.com/OptimalBits/bull).
This package was created with the purpose of solving some problems with the original "moleculer-bull" package, with a new logic this module allows to run jobs manually using "methods" this to avoid "duplication of jobs when the service starts" , it also supports repetitive jobs just like "bull" does, each task is restarted every time the service stops thus avoiding task overload and "double-run"
The main idea of this package is to allow it to support multiple types of "queue" like (bee-queue, cron, etc) in the same way as a task monitor, so far it supports only "bull"
## Installation
Install my-project with npm
```bash
npm install moleculer-queues --save
```or
```bash
yarn add moleculer-queues
```## Usage/Examples
```javascript
const MoleculerQueues = require('moleculer-queues');broker.createService({
name: 'service-example',
//Default redis is "localhost"
mixins: [MoleculerQueues('PrefixName', { redis: 'redis://127.0.0.1:6379' })],
methods: {
yourMethod(payload) {
//Some logic...this.addJobQueue('SendEmail', {
//Your playload data..
});
},
},
queues: [
{
name: 'SendEmail',
async handler(job, done) {
this.logger.info('Sending notification..');//Some logic...
return done(null, {
message: 'Notification sent!',
});
},
},
],
});
```## To-do
- [ ] Unit Testing
- [ ] Real Example
- [ ] Add support for multiples "queues packages"
- [ ] Allow to add custom "queue processor"