microwork eslint travis-ci npm

Microwork - simple creation of distributed scalable microservices in node.js with RabbitMQ

Microwork.js

npm MIT Build Status bitHound Overall Score Coverage Status Code docs

Microwork.js is a library for simple creation of distributed scalable microservices 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

  • Simple interface for building distributed (micro)services
  • Easy way to scale services both horizontally (by adding more nodes) and vertically (by adding more subscribers)
  • Extensible with plugins

Usage

Quick start

Example service that subscribe to messages from do.work topic and does some work with incoming data (in this case it just appends world! to incoming string):

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.subscribe('do.work', (msg, reply) => {
    reply('response.topic', msg + ' world!');
});
// after work is done - cleanup
await runner.stop();

Example service that subscribes to messages from response.topic and logs them to console, as well as sends processing request to previously defined 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();

For more examples see project documentation.

License

MIT

Related Repositories

microwork

microwork

Microwork - simple creation of distributed scalable microservices in node.js with RabbitMQ ...

microwork-rpc-handler

microwork-rpc-handler

A little handler that allow to send microservices RPC Request with microwork package ...


Top Contributors

yamalight

Releases

-   0.8.0 zip tar
-   0.7.1 zip tar
-   0.7.0 zip tar
-   0.6.0 zip tar
-   0.5.1 zip tar
-   0.5.0 zip tar
-   0.4.0 zip tar
-   0.3.0 zip tar
-   0.2.0 zip tar