When calling arnavmq multiple times to create multiple connections to different servers, it does not actually create a new connection each time. Instead, it just replaces the configuration of the old connection.
When calling the arnavmq lib it does:
|
return require('./modules/arnavmq')(connection(configuration)); |
While the connection function just returns the same singleton with updated configuration:
|
let instance; |
|
|
|
module.exports = (config) => { |
|
assert(instance || config, 'Connection can not be created because config does not exist'); |
|
assert(config.hostname); |
|
if (!instance) { |
|
instance = new Connection(config); |
|
} else { |
|
instance.config = config; |
|
} |
|
return instance; |
|
}; |
When calling arnavmq multiple times to create multiple connections to different servers, it does not actually create a new connection each time. Instead, it just replaces the configuration of the old connection.
When calling the arnavmq lib it does:
node-arnavmq/src/index.js
Line 50 in 452be98
While the
connectionfunction just returns the same singleton with updated configuration:node-arnavmq/src/modules/connection.js
Lines 95 to 106 in 452be98