@stepdi/tarantool-queue

1.0.4 • Public • Published

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.

and extra function:

  • getAll() – select all items from queue

Readme

Keywords

Package Sidebar

Install

npm i @stepdi/tarantool-queue

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

7.17 kB

Total Files

4

Last publish

Collaborators

  • stepdi