@highoutput/amqp
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -35,11 +35,17 @@ "use strict"; | ||
this.connection.on('disconnected', () => { | ||
logger_1.default.tag(['client', 'connection', 'disconnected']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
this.connection.on('connection_close', () => { | ||
logger_1.default.tag(['client', 'connection', 'connection_close']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
this.receiverQueueAddress = `temp-queue://${this.id}:${this.queue}`; | ||
} | ||
async send(...args) { | ||
var _a; | ||
if (this.shuttingDown) { | ||
throw new error_1.default('CLIENT_ERROR', 'Client shutting down.'); | ||
} | ||
if (this.disconnected && this.initialize !== null) { | ||
if (this.disconnected) { | ||
await this.start(); | ||
@@ -54,3 +60,3 @@ } | ||
if (!this.sender || this.sender.is_closed()) { | ||
throw new error_1.default('CLIENT_ERROR', 'Client sender is on invalid state.'); | ||
throw new error_1.default('CLIENT_ERROR', `Client sender is on invalid state. sender = ${!!this.sender}, closed = ${(_a = this.sender) === null || _a === void 0 ? void 0 : _a.is_closed()}`); | ||
} | ||
@@ -99,3 +105,10 @@ if (!this.receiver || this.receiver.is_closed()) { | ||
} | ||
logger_1.default.tag(['client', 'start']).info('Initializing client...'); | ||
this.initialize = (async () => { | ||
if (this.receiver) { | ||
this.receiver.close(); | ||
} | ||
if (this.sender) { | ||
this.sender.close(); | ||
} | ||
const [sender, receiver] = await Promise.all([ | ||
@@ -139,2 +152,4 @@ util_1.openSender(this.connection, { | ||
this.initialize = null; | ||
this.disconnected = false; | ||
logger_1.default.tag(['client', 'start']).info('Client initialized.'); | ||
})(); | ||
@@ -141,0 +156,0 @@ return this.initialize; |
@@ -24,4 +24,9 @@ "use strict"; | ||
this.connection.on('disconnected', () => { | ||
logger_1.default.tag(['publisher', 'connection', 'disconnected']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
this.connection.on('connection_close', () => { | ||
logger_1.default.tag(['publisher', 'connection', 'connection_close']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
logger_1.default.tag('publisher').info(this.options); | ||
@@ -33,3 +38,3 @@ } | ||
} | ||
if (this.disconnected && this.initialize !== null) { | ||
if (this.disconnected) { | ||
await this.start(); | ||
@@ -58,2 +63,3 @@ } | ||
} | ||
logger_1.default.tag(['publisher', 'start']).info('Initializing publisher...'); | ||
this.initialize = (async () => { | ||
@@ -68,2 +74,3 @@ this.sender = await util_1.openSender(this.connection, { | ||
this.initialize = null; | ||
logger_1.default.tag(['publisher', 'start']).info('Publisher initialized.'); | ||
})(); | ||
@@ -70,0 +77,0 @@ return this.initialize; |
@@ -26,2 +26,10 @@ "use strict"; | ||
}); | ||
this.connection.on('disconnected', () => { | ||
logger_1.default.tag(['subscriber', 'connection', 'disconnected']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
this.connection.on('connection_close', () => { | ||
logger_1.default.tag(['subscriber', 'connection', 'connection_close']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
logger_1.default.tag('subscriber').info(this.options); | ||
@@ -47,2 +55,3 @@ } | ||
} | ||
logger_1.default.tag(['subscriber', 'start']).info('Initializing subscriber...'); | ||
const connect = async () => { | ||
@@ -72,2 +81,3 @@ this.receiver = await util_1.openReceiver(this.connection, { | ||
this.disconnected = false; | ||
logger_1.default.tag(['subscriber', 'start']).info('Subscriber initialized.'); | ||
}); | ||
@@ -74,0 +84,0 @@ this.connection.on('disconnected', () => { |
@@ -29,2 +29,10 @@ "use strict"; | ||
}); | ||
this.connection.on('disconnected', () => { | ||
logger_1.default.tag(['worker', 'connection', 'disconnected']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
this.connection.on('connection_close', () => { | ||
logger_1.default.tag(['worker', 'connection', 'connection_close']).tag('Setting disconnected.'); | ||
this.disconnected = true; | ||
}); | ||
logger_1.default.tag('worker').info(this.options); | ||
@@ -34,2 +42,6 @@ } | ||
let promise = this.senders.get(address); | ||
if (promise && (await promise).is_closed()) { | ||
this.senders.delete(address); | ||
promise = undefined; | ||
} | ||
if (!promise) { | ||
@@ -104,5 +116,2 @@ promise = util_1.openSender(this.connection, { | ||
await connect(); | ||
this.connection.on('disconnected', () => { | ||
this.disconnected = true; | ||
}); | ||
this.connection.on('connection_open', async () => { | ||
@@ -109,0 +118,0 @@ if (!this.disconnected || this.shuttingDown) { |
{ | ||
"name": "@highoutput/amqp", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "A simplified abstraction of the AMQP 1.0 protocol", | ||
@@ -53,3 +53,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "d6daf68383c678323a8567084a522d9682ff5ce7" | ||
"gitHead": "00381c5392a5ce38f2092785f5eb3f574bd183fd" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
66546
839