Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/topliceanu/easter

Amqp/Http pub/sub client for RabbitMQ
https://github.com/topliceanu/easter

Last synced: 1 day ago
JSON representation

Amqp/Http pub/sub client for RabbitMQ

Awesome Lists containing this project

README

        

# Easter

## Gist

**easter** is a RabbitMQ publish/subscribe client with support for both AMQP and HTTP protocols.

## Status

[![NPM](https://nodei.co/npm/easter.png?downloads=true&stars=true)](https://nodei.co/npm/easter/)

[![NPM](https://nodei.co/npm-dl/easter.png?months=12)](https://nodei.co/npm-dl/easter/)

| Indicator | |
|:-----------------------|:-------------------------------------------------------------------------|
| documentation | [![Docs Coverage](https://img.shields.io/badge/docs-100%25-green.svg)](http://topliceanu.github.io/easter) |
| continuous integration | [![Build Status](https://travis-ci.org/topliceanu/easter.svg?branch=master)](https://travis-ci.org/topliceanu/easter) |
| dependency management | [![Dependency Status](https://david-dm.org/topliceanu/easter.svg?style=flat)](https://david-dm.org/topliceanu/easter) [![devDependency Status](https://david-dm.org/topliceanu/easter/dev-status.svg?style=flat)](https://david-dm.org/topliceanu/easter#info=devDependencies) |
| code coverage | [![Coverage Status](https://coveralls.io/repos/topliceanu/easter/badge.svg?branch=master)](https://coveralls.io/r/topliceanu/easter?branch=master) |
| examples | [/examples](https://github.com/topliceanu/easter/tree/master/examples) |
| change log | [CHANGELOG](https://github.com/topliceanu/easter/blob/master/CHANGELOG.md) [Releases](https://github.com/topliceanu/easter/releases) |

## Features

- Simple API, just a `publish()` and a `subscribe()`.
- Support for AMQP and HTTP, same api which makes them interchangeable.
- Transparent queue creation and management.
- Sensible defaults for the large set of available configuration options.

## Install

```shell
npm install easter
```

## Quick Example

```javascript
easter = require('easter');

// easter provides singleton methods for convenience but you can just as well
// use the base classes: RabbitAmqpClient and RabbitHttpClient.
amqpClient = easter.singleton('amqp', {host: 'localhost', port: 5672});
httpClient = easter.singleton('http', {host: 'localhost', port: 15672});

// The queue is created behind the scenes, if it does not exist yet.
amqpClient.subscribe('my-test-queue', function (error, message, consume) {
consume(); // In this case we are consuming the message immediately!
if(error) {
return console.log('Failed to connect/fetch message from queue', error);
}
console.log('Consumed message from queue');
});

console.log('Publishing message on the queue');
httpClient.publish('my-test-queue', 'hello easter rabbitmq');

// Note that httpClient and amqpClient are interchangeable.
```

More examples are in the `/examples` directory, they include instructions on __how to run and test__.

## Contributing

1. Contributions to this project are more than welcomed!
- Anything from improving docs, code cleanup to advanced functionality is greatly appreciated.
- Before you start working on an idea, please open an issue and describe in detail what you want to do and __why it's important__.
- You will get an answer in max 12h depending on your timezone.
2. Fork the repo!
3. If you use [vagrant](https://www.vagrantup.com/) then simply clone the repo into a folder then issue `$ vagrant up`
- if you don't use it, please consider learning it, it's easy to install and to get started with.
- If you don't use it, then you have to:
- install `rabbitmq-server` and enable `rabbitmq_management` plugin.
- install node.js and all node packages required in development using `$ npm install`
- For reference, see `./vagrant_boostrap.sh` for instructions on how to setup all dependencies on a fresh ubuntu 14.04 machine.
- Run the tests to make sure you have a correct setup: `$ npm run test`
4. Create a new branch and implement your feature.
- make sure you add tests for your feature. In the end __all tests have to pass__! To run test suite `$ npm run test`.
- make sure test coverage does not decrease! Run `$ npm run coverage` to open a browser window with the coverage report.
- make sure you document the code and coverage is > 90%. Run `$ npm run doc` to generate the docs and check if they look ok.
- make sure source code and test code are linted. Run `$ npm run lint`
- submit a pull request with your code.
- hit me up for a code review!
5. Have my kindest thanks for making this project better!

## Licence

(The MIT License)

Copyright (c) 2016 Alexandru Topliceanu ([email protected])

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.