Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/j3k0/node-local-jobs

Prevent two runs of the same job in parallel.
https://github.com/j3k0/node-local-jobs

Last synced: 22 days ago
JSON representation

Prevent two runs of the same job in parallel.

Awesome Lists containing this project

README

        

# Local Jobs runner

Prevents running the same job multiple times, on the same worker.

## Install

```sh
npm install local-jobs
```

## Usage

```js
var jobs = require("local-jobs");

var wait = function(cb) {
console.log("doing wait");
setTimeout(cb, 1000);
};

var waitDone = function() {
console.log("wait done");
};

jobs.do("wait", wait, waitDone);
jobs.do("wait", wait, waitDone);
jobs.do("wait", wait, waitDone);
```

Will run `wait` only once.
Will call `waitDone` three times.