pateka - ordered parallel asynchronous tasks
Installation
$ npm install pateka
Usage
Creating a new pateka. By default a pateka will be created with (parallel) 256 tracks, each track than will be filled with async tasks based on their routing key. Tasks in the same track ( same routing key ) will be run in order, tracks will be run in parallel.
const Pateka = ; const Pateka = ;
Setting the number of (parallel) tracks
You can chnage the default number of tracks by passing a tracks
option to the constructor.
const Pateka = tracks: 128 ;
Adding tasks
Task are added with the add
method. You will need to specify an id
for the task, a task
function, and a routingKey
.
The routingKey will be used to spread tasks into tracks, ensuring that tasks with the same key are always run in the right order and sequence.
pateka; pateka;
Awaiting a task to be done
await pateka;
License
Copyright (c) 2018 eCollect AG. Licensed under the MIT license.