# round-robin

> Round robin task scheduler

Latest version **1.0.0** (published 2013-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install round-robin
pnpm add round-robin
yarn add round-robin
bun add round-robin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2013-06-14 |
| First published | 2013-06-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alan Shaw |
| Maintainers | alanshaw |

## Links

- npm: https://www.npmjs.com/package/round-robin
- Repository: https://github.com/alanshaw/node-round-robin
- Issues: https://github.com/alanshaw/node-round-robin/issues
- npm.io page: https://npm.io/package/round-robin

## Dependencies (1)

- [async](https://npm.io/package/async.md) ~0.2.9

## Recent versions

- 1.0.0 (latest) — 2013-06-14
- 0.0.1 — 2013-06-10
- 0.0.0 — 2013-06-10

## README

Round Robin [![Dependency Status](https://david-dm.org/alanshaw/node-round-robin.png)](https://david-dm.org/alanshaw/node-round-robin) [![Build Status](https://travis-ci.org/alanshaw/node-round-robin.png)](https://travis-ci.org/alanshaw/node-round-robin) [![Coverage Status](https://coveralls.io/repos/alanshaw/node-round-robin/badge.png?branch=master)](https://coveralls.io/r/alanshaw/node-round-robin?branch=master)
===

Create consumers that expire after a certain time period or task count that are scheduled to be used in a round robin fashion.

How to
---

```javascript

var RoundRobin = require("round-robin").RoundRobin

var scheduler = new RoundRobin({

  // Create a new thing to do tasks
  spinUp: function (cb) {
    var thing = {doTask: function() {}, destroy: function() {}};
    cb(null, thing); // Remember to call the callback when ready
  },
  
  // Tear down the thing, it won't be used again!
  spinDown: function(thing, cb) {
    thing.destroy();
    cb(); // Remember to call the callback when done!
  },
  
  maxUp: 10, // Allow at most 10 things to be spun up at once
  maxUsage: 100, // Allow the thing to be used 100 times before it is spun down
  maxAge: 1000 * 60 * 60, // Allow the thing to live for an hour before it is spun down
  lazySpinDown: true // Spin down lazily (avoids the polling interval processing)
});

// Use the scheduler to get a thing and perform a task every second
var intervalId = setInterval(function () {
  scheduler.get(function (er, thing) {
    thing.doTask();
    scheduler.ret(thing); // Return the thing so the scheduler can hand it out again
  })
}, 1000);

// Finish doing tasks after 5 minutes
setTimeout(function () {
  clearInterval(intervalId);
  
  scheduler.destroy(function (er) {
    console.log("Finished doing tasks");
  })
}, 1000 * 60 * 5);

```

---
_Source: https://npm.io/package/round-robin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
