0.11.2 • Published 6 years ago

worque v0.11.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

worque

AMQP-based work queue.

Build Status Coverage Status

Installation

npm i worque --save

Description

Each task = queue.

Publishing message = loading single worker with task.

NOTE: one-by-one task processing is guaranteed only with RabbitMQ 3.3 and higher.

Motivation

  • simple project bootstrap
  • task survives broker restarts
  • task waits for worker (handler) if it's offline
  • task can be scheduled (cron)
  • task can be retried with flexible and easy-to-specify retry period configuration
  • fluent and simple API

Example

var client = require('worque')('amqp://localhost');

// global (all tasks) events
client.on('task', console.log); // fired before handler
client.on('result', console.log); // fired after handler
client.on('failure', console.error); // fired if handler fails

// define task 'logthis' and provide handler
client('logthis').subscribe(function (message) {
	console.log(message);
});

// start 'logthis' task with params
client('logthis').publish({ something: 42 });

// setup scheduled task
client('recurrent task runs each minute').subscribe(function () {
	console.log('I run each minute');
}).schedule('0 * * * * *');

// will be retried (republished) 1 second after 1st failure
// 2 seconds after 2nd failure
// 3 seconds after 3d failure
client('retry 3 times if failed').subscribe(function (url) {
	return doRequestAndSaveToFile(url);
}).retry(1, 2, 3).publish('http://mysite.com');

process.on('SIGINT', function () {
	client.close();
});

License

MIT

0.11.2

6 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.6

7 years ago

0.10.5

8 years ago

0.10.4

8 years ago

0.9.3

8 years ago

0.9.2

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago

0.6.6

8 years ago

0.6.5

8 years ago

0.6.4

8 years ago

0.6.3

8 years ago

0.6.2

8 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.9

9 years ago

0.4.8

9 years ago

0.4.7

9 years ago

0.4.6

9 years ago

0.4.5

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago