@stepdi/tarantool-queue
v1.0.4
Published
Wrapper for Tarantool Queue
Downloads
1
Readme
tarantool-queue
Simple wrapper for Tarantool Queue for NodeJS (ES6). It accepts Tarantool connection from tarantool/node-tarantool-driver
Module Queue for Tarantool is required (if you use Official Tarantool Docker image you already have it, if you do not please install the Queue module - here is described how) To check if you have the Queue module installed run in your Tarantool console:
Lua> queue = require('queue')
Install
npm i @stepdi/tarantool-queue
Sample usage (worker):
import Tarantool from 'tarantool-driver';
import TarantoolQueue from '@stepdi/tarantool-queue';
async function worker() {
let conn = new Tarantool({ port: 3301 });
let q = new TarantoolQueue(conn, 'myQueue');
async function processTask(t) {
return new Promise((resolve, reject) => {
q.ack(t[0][0]).then(resolve).catch(reject);
});
}
try {
let task;
while (task = await q.take()) {
await processTask(task);
}
} catch (err) {
console.log('Error:', err);
}
}
worker();
Functions supported
Please refer to Tarantool Queue module documentation using links in the list. Every function returns a Promise which resolves with data from Tarantool or rejects with error message.
- create_tube(type = 'fifo', temporary = true)
- drop()
- put(taskData, options)
- take(timeout)
- touch(taskId, increment)
- ack(taskId)
- release(taskId, options)
- peek(taskId)
- bury(taskId)
- kick(count)
- delete(taskId)
- statistics()
and extra function:
- getAll() – select all items from queue