pipeline-queue
v2.0.0
Published
A simple request or action queue.
Downloads
26
Readme
pipeline-queue
A simple queuing mechanism that can pipeline requests for a long running resource request. By using this queue you can make multiple requests to the resource but the resource will only receive traffic as fast as it will respond.
Installation
Just use npm to install.
npm install pipeline-queue
Usage
var PipelineQueue = require('pipeline-queue'),
queue = PipelineQueue();
key = 'unique-key';
task = function () { //do something that takes a long time. };
callback1 = function (results) { // handle the response. };
queue.run(key, task, callback1);
//make a second request
callback2 = function (results) { // handle the response. };
queue.run(key, task, callback2); //if the task has not completed yet,
//then our callback will be queued and the task will not be run.
//Our callback will receive the results of the initial task run.