-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
54 lines (41 loc) · 2.04 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const utils = require('./modules/utils');
const connection = require('./modules/connection');
const { ARNAVMQ_TRANSPORT_LOGGER_DEPRECATED } = require('./modules/warnings');
/* eslint global-require: "off" */
module.exports = (config) => {
const configuration = {
// amqp connection string
host: 'amqp://localhost',
// number of fetched messages, at once
prefetch: 5,
// requeue put back message into the broker if consumer crashes/trigger exception
requeue: true,
// time between two reconnect (ms)
timeout: 1000,
// the maximum number of retries when trying to send a message before throwing error when failing. If set to '0' will not retry. If set to less then '0', will retry indefinitely.
producerMaxRetries: -1,
// default timeout for RPC calls. If set to '0' there will be none.
rpcTimeout: 15000,
// suffix all queues names
// ex: service-something with suffix :ci becomes service-suffix:ci etc.
consumerSuffix: '',
// generate a hostname so we can track this connection on the broker (rabbitmq management plugin)
hostname: process.env.HOSTNAME || process.env.USER || utils.uuidV4(),
// Deprecated. Use 'logger' instead. The transport to use to debug. If provided, arnavmq will show some logs
transport: utils.emptyLogger,
/**
* A logger object with a log function for each of the log levels ("debug", "info", "warn", or "error").
* Each log function receives one parameter containing a log event with the following fields:
* * message - A string message describing the event. Always present.
* * error - An 'Error' object in case one is present.
* * params - An optional object containing extra parameters that can provide extra context for the event.
*/
logger: utils.emptyLogger,
...config
};
if (configuration.transport !== utils.emptyLogger) {
utils.emitWarn(ARNAVMQ_TRANSPORT_LOGGER_DEPRECATED);
}
configuration.prefetch = parseInt(configuration.prefetch, 10) || 0;
return require('./modules/arnavmq')(connection(configuration));
};