-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.js
36 lines (33 loc) · 874 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict';
/**
* Plugin that allows Seneca listeners
* and clients to communicate over AMQP 0-9-1.
*
* @module seneca-amqp-transport
*/
const defaults = require('./defaults');
const hooks = require('./lib/hooks');
const PLUGIN_NAME = 'amqp-transport';
const PLUGIN_TAG = require('./package.json').version;
const TRANSPORT_TYPE = 'amqp';
module.exports = function(opts) {
var seneca = this;
var so = seneca.options();
var options = seneca.util.deepextend(defaults, so.transport, opts);
var listener = hooks.listenerHook(seneca);
var client = hooks.clientHook(seneca);
seneca.add({
role: 'transport',
hook: 'listen',
type: TRANSPORT_TYPE
}, listener.hook(options));
seneca.add({
role: 'transport',
hook: 'client',
type: TRANSPORT_TYPE
}, client.hook(options));
return {
tag: PLUGIN_TAG,
name: PLUGIN_NAME
};
};