@jackrabbit/channel
Version:
wrapper for creating a rabbitMQ connection and opening a channel
64 lines (43 loc) • 1.63 kB
Markdown
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]
> wrapper for creating a rabbitMQ connection and opening a channel
It gets tedious to start every rabbit interaction with the same two function
calls:
```js
const Amqp = require('amqplib/callback_api')
Amqp.connect(url, options, (err, connection) => {
if (err) throw err
connection.createChannel((err, channel) => {
if (err) throw err
// ready to start actually scripting
})
})
```
Additionally, using this module abstracts the dependency on `amqplib` (a little).
```
npm install @jackrabbit/channel
```
The exported function takes the same parameters as [`amqplib.connect`][amqplib],
and yields `channel` and `connection` objects.
```js
const RabbitChannel = require('@jackrabbit/channel')
RabbitChannel(url, options, (err, channel, connection) {
if (err) throw err
// script away
})
```
Contributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.
[](LICENSE.md)
[]: https://img.shields.io/npm/v/@jackrabbit/channel.svg?style=flat-square
[]: https://www.npmjs.com/package/@jackrabbit/channel
[]: https://img.shields.io/travis/jackboberg/rabbit-channel.svg?style=flat-square
[]: https://travis-ci.org/jackboberg/rabbit-channel
[]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[]: http://npm.im/standard
[]: http://www.squaremobius.net/amqp.node/channel_api.html#connect