@highoutput/amqp
Advanced tools
Comparing version 0.5.14 to 0.6.0
@@ -25,3 +25,2 @@ import Client, { ClientOptions } from './lib/client'; | ||
private container; | ||
private connection; | ||
private workers; | ||
@@ -31,3 +30,5 @@ private clients; | ||
private subscribers; | ||
private _connection?; | ||
constructor(options?: Partial<AmqpOptions>); | ||
private get connection(); | ||
createClient<TInput extends any[] = any[], TOutput = any>(queue: string, options?: Partial<ClientOptions>): Promise<{ | ||
@@ -34,0 +35,0 @@ (...args: TInput): Promise<TOutput | null>; |
@@ -35,18 +35,23 @@ "use strict"; | ||
logger_1.default.tag(['amqp', 'options']).info(ramda_1.default.omit(['password'], this.options)); | ||
this.connection = this.container.connect(Object.assign(Object.assign({}, this.options), { reconnect: true, initial_reconnect_delay: this.options.initialReconnectDelay, max_reconnect_delay: this.options.maxReconnectDelay })); | ||
this.connection.setMaxListeners(100); | ||
this.connection.on('connection_open', () => { | ||
logger_1.default.info('connection established'); | ||
}); | ||
this.connection.on('connection_close', () => { | ||
logger_1.default.info('connection closed'); | ||
}); | ||
this.connection.on('connection_error', (context) => { | ||
var _a; | ||
logger_1.default.error((_a = context.error) === null || _a === void 0 ? void 0 : _a.message); | ||
}); | ||
this.connection.on('disconnected', () => { | ||
logger_1.default.info('disconnected'); | ||
}); | ||
} | ||
get connection() { | ||
if (!this._connection) { | ||
this._connection = this.container.connect(Object.assign(Object.assign({}, this.options), { reconnect: true, initial_reconnect_delay: this.options.initialReconnectDelay, max_reconnect_delay: this.options.maxReconnectDelay })); | ||
this.connection.setMaxListeners(100); | ||
this.connection.on('connection_open', () => { | ||
logger_1.default.info('connection established'); | ||
}); | ||
this.connection.on('connection_close', () => { | ||
logger_1.default.info('connection closed'); | ||
}); | ||
this.connection.on('connection_error', (context) => { | ||
var _a; | ||
logger_1.default.error((_a = context.error) === null || _a === void 0 ? void 0 : _a.message); | ||
}); | ||
this.connection.on('disconnected', () => { | ||
logger_1.default.info('disconnected'); | ||
}); | ||
} | ||
return this._connection; | ||
} | ||
async createClient(queue, options) { | ||
@@ -94,6 +99,7 @@ const client = new client_1.default(this.connection, `${this.options.prefix || ''}${queue}`, options); | ||
]); | ||
this.connection.close(); | ||
await new Promise((resolve) => { | ||
const promise = new Promise((resolve) => { | ||
this.connection.once('connection_close', resolve); | ||
}); | ||
this.connection.close(); | ||
await promise; | ||
} | ||
@@ -100,0 +106,0 @@ } |
{ | ||
"name": "@highoutput/amqp", | ||
"version": "0.5.14", | ||
"version": "0.6.0", | ||
"description": "A simplified abstraction of the AMQP 1.0 protocol", | ||
@@ -57,3 +57,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "42e1cf5de0aaa4d0c91571969bfd04a98ee27505" | ||
"gitHead": "28da4cfd830812899fde70e29fb96bb69d2729c3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
69703
879
0