Microwork.js
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 and it uses async/await - it requires latest stable node (7.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):
const Microwork = ; // create task runnerconst runner = host: 'your.rabbit.host' exchange: 'your.exchange';// add worker to specific topicawait runner;// after work is done - cleanupawait runner;
Example service that subscribes to messages from response.topic
and logs them to console, as well as sends processing request to previously defined service:
const Microwork = ; // create masterconst master = host: 'your.rabbit.host' exchange: 'your.exchange';// listen for reply from workersawait master;// send message to workersawait master; // after work is done - cleanupawait master;
For more examples see project documentation.