@mariosant/work

0.2.0 • Public • Published

Work

Guaranteed to do the work!

ko-fi

NPM version CircleCI

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.
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Readme

Keywords

none

Package Sidebar

Install

npm i @mariosant/work

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

12.9 kB

Total Files

25

Last publish

Collaborators

  • mariosant