1.0.4 • Published 5 years ago

@stepdi/tarantool-queue v1.0.4

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

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
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago