rhea-promise
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -0,1 +1,6 @@ | ||
### 0.1.11 - 2018-11-15 | ||
- Added checks for some event handler methods to exist before logging information that uses node's | ||
event handlers inbuilt functions. | ||
- Improved error checking while creating the receiver. | ||
### 0.1.10 - 2018-11-01 | ||
@@ -2,0 +7,0 @@ - Provided an option to add an event handler for "settled" event on the Receiver. |
@@ -118,3 +118,3 @@ "use strict"; | ||
log.connection("[%s] Resolving the promise with amqp connection.", this.id); | ||
resolve(this); | ||
return resolve(this); | ||
}; | ||
@@ -125,3 +125,3 @@ onClose = (context) => { | ||
log.error("[%s] Error occurred while establishing amqp connection: %O", this.id, err); | ||
reject(err); | ||
return reject(err); | ||
}; | ||
@@ -132,3 +132,3 @@ const actionAfterTimeout = () => { | ||
log.error("[%s] %s", this.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -145,3 +145,3 @@ // listeners that we add for completing the operation are added directly to rhea's objects. | ||
else { | ||
resolve(this); | ||
return resolve(this); | ||
} | ||
@@ -173,3 +173,3 @@ }); | ||
log.connection("[%s] Resolving the promise as the connection has been successfully closed.", this.id); | ||
resolve(); | ||
return resolve(); | ||
}; | ||
@@ -179,3 +179,3 @@ onError = (context) => { | ||
log.error("[%s] Error occurred while closing amqp connection: %O.", this.id, context.connection.error); | ||
reject(context.connection.error); | ||
return reject(context.connection.error); | ||
}; | ||
@@ -186,3 +186,3 @@ const actionAfterTimeout = () => { | ||
log.error("[%s] %s", this.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -197,3 +197,3 @@ // listeners that we add for completing the operation are added directly to rhea's objects. | ||
else { | ||
resolve(); | ||
return resolve(); | ||
} | ||
@@ -273,3 +273,3 @@ }); | ||
log.session("[%s] Resolving the promise with amqp session.", this.id); | ||
resolve(session); | ||
return resolve(session); | ||
}; | ||
@@ -279,3 +279,3 @@ onClose = (context) => { | ||
log.error("[%s] Error occurred while establishing a session over amqp connection: %O.", this.id, context.session.error); | ||
reject(context.session.error); | ||
return reject(context.session.error); | ||
}; | ||
@@ -286,3 +286,3 @@ const actionAfterTimeout = () => { | ||
log.error("[%s] %s", this.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -440,4 +440,6 @@ // listeners that we add for completing the operation are added directly to rhea's objects. | ||
}); | ||
log.eventHandler("[%s] rhea-promise 'connection' object is listening for events: %o " + | ||
"emitted by rhea's 'connection' object.", this.id, this._connection.eventNames()); | ||
if (typeof this._connection.eventNames === "function") { | ||
log.eventHandler("[%s] rhea-promise 'connection' object is listening for events: %o " + | ||
"emitted by rhea's 'connection' object.", this.id, this._connection.eventNames()); | ||
} | ||
} | ||
@@ -444,0 +446,0 @@ } |
@@ -203,3 +203,3 @@ "use strict"; | ||
log[this.type]("[%s] Resolving the promise as the amqp %s has been closed.", this.connection.id, this.type); | ||
resolve(); | ||
return resolve(); | ||
}; | ||
@@ -209,3 +209,3 @@ onError = (context) => { | ||
log.error("[%s] Error occurred while closing amqp %s: %O.", this.connection.id, this.type, context.session.error); | ||
reject(context.session.error); | ||
return reject(context.session.error); | ||
}; | ||
@@ -216,3 +216,3 @@ const actionAfterTimeout = () => { | ||
log.error("[%s] %s", this.connection.id, this.type, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -227,3 +227,3 @@ // listeners that we add for completing the operation are added directly to rhea's objects. | ||
else { | ||
resolve(); | ||
return resolve(); | ||
} | ||
@@ -255,5 +255,9 @@ }); | ||
} | ||
log.eventHandler("[%s] rhea-promise '%s' object is listening for events: %o " + | ||
"emitted by rhea's '%s' object.", this.connection.id, this.type, this._link.eventNames(), this.type); | ||
log.eventHandler("[%s] ListenerCount for event '%s_error' on rhea's '%s' object is: %d.", this.connection.id, this.type, this.type, this._link.listenerCount(`${this.type}_error`)); | ||
if (typeof this._link.eventNames === "function") { | ||
log.eventHandler("[%s] rhea-promise '%s' object is listening for events: %o " + | ||
"emitted by rhea's '%s' object.", this.connection.id, this.type, this._link.eventNames(), this.type); | ||
} | ||
if (typeof this._link.listenerCount === "function") { | ||
log.eventHandler("[%s] ListenerCount for event '%s_error' on rhea's '%s' object is: %d.", this.connection.id, this.type, this.type, this._link.listenerCount(`${this.type}_error`)); | ||
} | ||
} | ||
@@ -260,0 +264,0 @@ } |
@@ -100,3 +100,3 @@ "use strict"; | ||
log.session("[%s] Resolving the promise as the amqp session has been closed.", this.connection.id); | ||
resolve(); | ||
return resolve(); | ||
}; | ||
@@ -123,3 +123,3 @@ onError = (context) => { | ||
else { | ||
resolve(); | ||
return resolve(); | ||
} | ||
@@ -141,4 +141,17 @@ }); | ||
((options.onMessage && !options.onError) || (options.onError && !options.onMessage))) { | ||
reject(new Error("Both onMessage and onError handlers must be provided if one of " + | ||
"them is provided.")); | ||
if (options.credit_window !== 0) { | ||
// - If the 'onMessage' handler is not provided and the credit_window is not set to 0, | ||
// then messages may be lost between the receiver link getting created and the message | ||
// handler being attached. | ||
// - It can be possible for a service to initially accept the link attach, which would | ||
// cause the promise to resolve. However, moments later the service may send a detach | ||
// due to some internal or configuration issue. If no error handler is attached, then | ||
// the error may fall through. | ||
// - Hence it is advised to either provide both 'onMessage' and 'onError' handlers, or | ||
// please set the credit_window to `0`, if you want to provide only the 'onError' handler. | ||
return reject(new Error("Either provide both 'onMessage' and 'onError' handlers, or pl" + | ||
"ease set the credit_window to 0, if you want to provide only the 'onError' " + | ||
"handler. This ensures no messages are lost between the receiver getting created " + | ||
" and the 'onMessage' handler being added.")); | ||
} | ||
} | ||
@@ -187,3 +200,3 @@ const handlersProvided = options && options.onMessage ? true : false; | ||
log.receiver("[%s] Resolving the promise with amqp receiver '%s'.", this.connection.id, receiver.name); | ||
resolve(receiver); | ||
return resolve(receiver); | ||
}; | ||
@@ -193,3 +206,3 @@ onClose = (context) => { | ||
log.error("[%s] Error occurred while creating a receiver over amqp connection: %O.", this.connection.id, context.receiver.error); | ||
reject(context.receiver.error); | ||
return reject(context.receiver.error); | ||
}; | ||
@@ -201,3 +214,3 @@ const actionAfterTimeout = () => { | ||
log.error("[%s] %s", this.connection.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -268,3 +281,3 @@ // listeners that we add for completing the operation are added directly to rhea's objects. | ||
log.sender("[%s] Resolving the promise with amqp sender '%s'.", this.connection.id, sender.name); | ||
resolve(sender); | ||
return resolve(sender); | ||
}; | ||
@@ -274,3 +287,3 @@ onClose = (context) => { | ||
log.error("[%s] Error occurred while creating a sender over amqp connection: %O.", this.connection.id, context.sender.error); | ||
reject(context.sender.error); | ||
return reject(context.sender.error); | ||
}; | ||
@@ -282,3 +295,3 @@ const actionAfterTimeout = () => { | ||
log.error("[%s] %s", this.connection.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -354,4 +367,6 @@ // listeners that we add for completing the operation are added directly to rhea's objects. | ||
}); | ||
log.eventHandler("[%s] rhea-promise 'session' object is listening for events: %o " + | ||
"emitted by rhea's 'session' object.", this.connection.id, this._session.eventNames()); | ||
if (typeof this._session.eventNames === "function") { | ||
log.eventHandler("[%s] rhea-promise 'session' object is listening for events: %o " + | ||
"emitted by rhea's 'session' object.", this.connection.id, this._session.eventNames()); | ||
} | ||
} | ||
@@ -358,0 +373,0 @@ } |
@@ -239,3 +239,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
log.connection("[%s] Resolving the promise with amqp connection.", this.id); | ||
resolve(this); | ||
return resolve(this); | ||
}; | ||
@@ -248,3 +248,3 @@ | ||
this.id, err); | ||
reject(err); | ||
return reject(err); | ||
}; | ||
@@ -256,3 +256,3 @@ | ||
log.error("[%s] %s", this.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -269,3 +269,3 @@ | ||
} else { | ||
resolve(this); | ||
return resolve(this); | ||
} | ||
@@ -301,3 +301,3 @@ }); | ||
this.id); | ||
resolve(); | ||
return resolve(); | ||
}; | ||
@@ -309,3 +309,3 @@ | ||
this.id, context.connection.error); | ||
reject(context.connection.error); | ||
return reject(context.connection.error); | ||
}; | ||
@@ -317,3 +317,3 @@ | ||
log.error("[%s] %s", this.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -328,3 +328,3 @@ | ||
} else { | ||
resolve(); | ||
return resolve(); | ||
} | ||
@@ -413,3 +413,3 @@ }); | ||
log.session("[%s] Resolving the promise with amqp session.", this.id); | ||
resolve(session); | ||
return resolve(session); | ||
}; | ||
@@ -421,3 +421,3 @@ | ||
this.id, context.session!.error); | ||
reject(context.session!.error); | ||
return reject(context.session!.error); | ||
}; | ||
@@ -429,3 +429,3 @@ | ||
log.error("[%s] %s", this.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -588,6 +588,7 @@ | ||
}); | ||
log.eventHandler("[%s] rhea-promise 'connection' object is listening for events: %o " + | ||
"emitted by rhea's 'connection' object.", this.id, this._connection.eventNames()); | ||
if (typeof this._connection.eventNames === "function") { | ||
log.eventHandler("[%s] rhea-promise 'connection' object is listening for events: %o " + | ||
"emitted by rhea's 'connection' object.", this.id, this._connection.eventNames()); | ||
} | ||
} | ||
} |
@@ -240,3 +240,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
this.connection.id, this.type); | ||
resolve(); | ||
return resolve(); | ||
}; | ||
@@ -248,3 +248,3 @@ | ||
this.connection.id, this.type, context.session!.error); | ||
reject(context.session!.error); | ||
return reject(context.session!.error); | ||
}; | ||
@@ -256,3 +256,3 @@ | ||
log.error("[%s] %s", this.connection.id, this.type, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -268,3 +268,3 @@ | ||
} else { | ||
resolve(); | ||
return resolve(); | ||
} | ||
@@ -298,8 +298,12 @@ }); | ||
} | ||
log.eventHandler("[%s] rhea-promise '%s' object is listening for events: %o " + | ||
"emitted by rhea's '%s' object.", this.connection.id, this.type, | ||
this._link.eventNames(), this.type); | ||
log.eventHandler("[%s] ListenerCount for event '%s_error' on rhea's '%s' object is: %d.", | ||
this.connection.id, this.type, this.type, this._link.listenerCount(`${this.type}_error`)); | ||
if (typeof this._link.eventNames === "function") { | ||
log.eventHandler("[%s] rhea-promise '%s' object is listening for events: %o " + | ||
"emitted by rhea's '%s' object.", this.connection.id, this.type, | ||
this._link.eventNames(), this.type); | ||
} | ||
if (typeof this._link.listenerCount === "function") { | ||
log.eventHandler("[%s] ListenerCount for event '%s_error' on rhea's '%s' object is: %d.", | ||
this.connection.id, this.type, this.type, this._link.listenerCount(`${this.type}_error`)); | ||
} | ||
} | ||
} |
@@ -127,3 +127,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
this.connection.id); | ||
resolve(); | ||
return resolve(); | ||
}; | ||
@@ -153,3 +153,3 @@ | ||
} else { | ||
resolve(); | ||
return resolve(); | ||
} | ||
@@ -172,4 +172,17 @@ }); | ||
((options.onMessage && !options.onError) || (options.onError && !options.onMessage))) { | ||
reject(new Error("Both onMessage and onError handlers must be provided if one of " + | ||
"them is provided.")); | ||
if (options.credit_window !== 0) { | ||
// - If the 'onMessage' handler is not provided and the credit_window is not set to 0, | ||
// then messages may be lost between the receiver link getting created and the message | ||
// handler being attached. | ||
// - It can be possible for a service to initially accept the link attach, which would | ||
// cause the promise to resolve. However, moments later the service may send a detach | ||
// due to some internal or configuration issue. If no error handler is attached, then | ||
// the error may fall through. | ||
// - Hence it is advised to either provide both 'onMessage' and 'onError' handlers, or | ||
// please set the credit_window to `0`, if you want to provide only the 'onError' handler. | ||
return reject(new Error("Either provide both 'onMessage' and 'onError' handlers, or pl" + | ||
"ease set the credit_window to 0, if you want to provide only the 'onError' " + | ||
"handler. This ensures no messages are lost between the receiver getting created " + | ||
" and the 'onMessage' handler being added.")); | ||
} | ||
} | ||
@@ -229,3 +242,3 @@ | ||
this.connection.id, receiver.name); | ||
resolve(receiver); | ||
return resolve(receiver); | ||
}; | ||
@@ -237,3 +250,3 @@ | ||
this.connection.id, context.receiver!.error); | ||
reject(context.receiver!.error); | ||
return reject(context.receiver!.error); | ||
}; | ||
@@ -246,3 +259,3 @@ | ||
log.error("[%s] %s", this.connection.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -321,3 +334,3 @@ | ||
this.connection.id, sender.name); | ||
resolve(sender); | ||
return resolve(sender); | ||
}; | ||
@@ -329,3 +342,3 @@ | ||
this.connection.id, context.sender!.error); | ||
reject(context.sender!.error); | ||
return reject(context.sender!.error); | ||
}; | ||
@@ -338,3 +351,3 @@ | ||
log.error("[%s] %s", this.connection.id, msg); | ||
reject(new Error(msg)); | ||
return reject(new Error(msg)); | ||
}; | ||
@@ -417,5 +430,7 @@ | ||
}); | ||
log.eventHandler("[%s] rhea-promise 'session' object is listening for events: %o " + | ||
"emitted by rhea's 'session' object.", this.connection.id, this._session.eventNames()); | ||
if (typeof this._session.eventNames === "function") { | ||
log.eventHandler("[%s] rhea-promise 'session' object is listening for events: %o " + | ||
"emitted by rhea's 'session' object.", this.connection.id, this._session.eventNames()); | ||
} | ||
} | ||
} |
{ | ||
"name": "rhea-promise", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "A Promisified layer over rhea AMQP client", | ||
@@ -23,7 +23,7 @@ "license": "Apache-2.0", | ||
"@types/node": "^8.0.37", | ||
"@types/dotenv": "^4.0.3", | ||
"@types/dotenv": "^6.1.0", | ||
"rimraf": "^2.6.2", | ||
"ts-node": "^7.0.1", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.3", | ||
"typescript": "^3.1.6", | ||
"dotenv": "^6.1.0" | ||
@@ -30,0 +30,0 @@ }, |
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
239504
4366