https://github.com/shimohq/tomqueue
A FIFO queue with group-level concurrency support
https://github.com/shimohq/tomqueue
concurrency fifo-queue nodejs
Last synced: 26 days ago
JSON representation
A FIFO queue with group-level concurrency support
- Host: GitHub
- URL: https://github.com/shimohq/tomqueue
- Owner: shimohq
- License: mit
- Created: 2016-08-08T09:30:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-29T08:17:21.000Z (over 8 years ago)
- Last Synced: 2025-08-24T19:28:00.999Z (about 1 month ago)
- Topics: concurrency, fifo-queue, nodejs
- Language: JavaScript
- Size: 17.6 KB
- Stars: 6
- Watchers: 6
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TomQueue
A FIFO queue with group-level concurrency support## Install
```shell
$ npm install tomqueue
```## Usage
Dispatcher:
```javascript
const Dispatcher = require('tomqueue').Dispatcher;
const dispatcher = new Dispatcher({
port: 7446
});dispatcher.start();
setTimeout(function () {
const payload = {
channel: 'abc',
baseRev: 67,
changeset: ''
};
dispatcher.send(payload).then((res) => {
console.log(res);
}).catch(console.error);
}, 3000);
```Worker:
```javascript
const Worker = require('tomqueue').Worker;
const worker = new Worker({
handler(payload) {
return processChangeset(payload);
}
});worker.start();
function processChangeset(data) {
return Promise.resolve(data);
}
```## Payload
The method `Dispatcher#send()` receives a payload object, which must contain a `channel` property representing which channel the payload should be sent to.
## Storage
TomQueue supports two storages. The default storage is memory based. To switch to the redis-based storage, set `storage` option to `"redis"`:
```javascript
const dispatcher = new Dispatcher({
port: 7446,
storage: 'redis',
storageOptions: {
redis: new Redis()
}
});
```