Home Reference Source Repository

Microwork.js

npm MIT Build Status bitHound Overall Score Coverage Status

Microwork.js is a library for simple creation of distributed scalable task runners in node.js with RabbitMQ.

Installation

npm install --save microwork

Requirements

Since Microwork.js is written in ES6, it uses babel to compile the code before publishing. Currently we're using es2015-node babel preset that only works in latest stable node (4.x or later).

Features

TODO: describe me

Usage

Quick start

Example runner service:

import Microwork from 'microwork';

// create task runner
const runner = new Microwork({host: 'your.rabbit.host', exchange: 'your.exchange'});
// add worker to specific topic
await runner.addWorker('do.work', (msg, reply) => {
    reply('response.topic', msg + ' world!');
});
// after work is done - cleanup
await runner.stop();

Example master service:

import Microwork from 'microwork';

// create master
const master = new Microwork({host: 'your.rabbit.host', exchange: 'your.exchange'});
// listen for reply from workers
await master.subscribe('response.topic', (msg) => {
    console.log(msg); // -> "hello world!"
});
// send message to workers
await master.send('do.work', 'hello');

// after work is done - cleanup
await master.stop();

TODO: more docs

License

MIT