@mariosant/work
Run lean rabbitmq consumers
Last updated a year ago by mariosant .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @mariosant/work 
SYNC missed versions from official npm registry.

Work

Guaranteed to do the work!

NPM version Build Status Commitizen friendly

Work is a framework for developing processing systems that rely on RabbitMQ. It provides the developer a simplified set of tools to build

Installation

Add @mariosant/work to your package.json.

$ npm install @mariosant/work

For local development, you might want run an instance of Rabbit MQ, via docker.

Usage

The idea is pretty simple. Develop modules that consume messages and run them via a cli tool or programmatically.

// consumer.js
const {getContent} = require('@mariosant/work')
const consume = (message. {publish, retry, reject}, context) => {
	const content = getContent(message);

	// Process the message here. No need to return anything.
	// Async/await is fully supported.

	// If you need to retry processing, call retry()
	// If you need to discard the message, call reject()
	// And if you need to publish a new message, call publish(topic, content)
};

const init = ({publish}) => {
	// anything you return here, it is going to be available in the consume's context
}

// Export the following
module.exports = {
	consume,
	init,
	uri: 'amqp://guest:guest@localhost',
	exchange: 'test-exchange',
	queue: 'service-name',
	routingKey: 'records.#',
};

And run it:

$ npx work consumer.js

Development

Easy-peasy!

$ yarn install        # to install dependencies
$ yarn test           # to run the test suite
$ docker-compose up   # run a local Rabbit MQ instance

Meta

Marios Antonoudiou – @marios_antmariosant@sent.com

Distributed under the MIT license.

https://github.com/mariosant/work

Contributing

  1. Fork it (https://github.com/mariosant/work/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes using a semantic commit message. I include a yarn commit script to help you out.
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Current Tags

  • 0.0.1                                ...           latest (a year ago)

1 Versions

  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |