https://github.com/scull7/pipeline-queue
A simple request queuing middleware for Express and like frameworks.
https://github.com/scull7/pipeline-queue
Last synced: over 1 year ago
JSON representation
A simple request queuing middleware for Express and like frameworks.
- Host: GitHub
- URL: https://github.com/scull7/pipeline-queue
- Owner: scull7
- License: gpl-2.0
- Created: 2014-05-04T01:17:05.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-08-15T17:46:36.000Z (almost 10 years ago)
- Last Synced: 2025-03-21T13:12:50.605Z (over 1 year ago)
- Language: JavaScript
- Size: 81.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/scull7/pipeline-queue)
[](https://coveralls.io/r/scull7/pipeline-queue)
[](https://codeclimate.com/github/scull7/pipeline-queue)
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.
```javascript
npm install pipeline-queue
```
Usage
-----
```javascript
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.
```