Socket
Book a DemoInstallSign in
Socket

conker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conker

A simple concurrency manager

latest
npmnpm
Version
0.1.2
Version published
Weekly downloads
7
250%
Maintainers
1
Weekly downloads
 
Created
Source

conker

A simple concurrency manager for nodejs. Basically this is to facilitate situations where you want to control the maximum number of async delegates that can be executed at any time for a single "concurrency key".

Getting Started

Install the module with: npm install conker

Examples

I have a remote API server, and want to ensure that I do no more than a maximum of 1 request at any given time, and subsequence requests should be queued until that point.

var conker = new require('conker')({
  maxPerKey: 1
});

var concurrencyKey = 'some-api-identifier';
conker
  .start(concurrencyKey, function(callback) {
    myApi.doSomething(callback);
  })
  .then(function(result) {
    // Success!  
  })
  .then(null, function(err) {
    // Fail :'(
  });

conker
  .start(concurrencyKey, function(callback) {
    // This request wont happen until the request above completes or fails, as our maxPerKey is set to 1
    myApi.doSomethingElse(callback);
  })
  .then(function(result) {
    // Success!  
  })
  .then(null, function(err) {
    // Fail :'(
  });

Contributing

TDD please. Write a test, pass it, refactor it and then submit a merge request.

Release History

  • 0.1.0 - Initial Release
  • 0.1.1 - Bug Fixes
  • 0.1.2 - Version bump

License

Copyright (c) 2014 Karl Stoney
Licensed under the MIT license.

FAQs

Package last updated on 07 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts