rhea-promise
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -0,1 +1,7 @@ | ||
### 0.1.14 - 2019-03-19 | ||
- Allow websockets usage on a connection without creating a container first. [PR](https://github.com/amqp/rhea-promise/pull/32). | ||
- New function `removeAllSessions()` on the connection to clear the internal map in rhea to ensure | ||
sessions are not reconnected on the next `connection.open()` call. [PR](https://github.com/amqp/rhea-promise/pull/33). | ||
- Remove all event listeners on link and session objects when `close()` is called on them. [PR](https://github.com/amqp/rhea-promise/pull/34) | ||
### 0.1.13 - 2018-12-11 | ||
@@ -2,0 +8,0 @@ - Throw `OperationTimeoutError` when a Promise to create/close an entity is rejected. |
@@ -40,3 +40,8 @@ "use strict"; | ||
else { | ||
this._connection = rhea_1.create_connection(options); | ||
const connectionOptions = options; | ||
if (connectionOptions.webSocketOptions) { | ||
const ws = rhea_1.websocket_connect(connectionOptions.webSocketOptions.webSocket); | ||
connectionOptions.connection_details = ws(connectionOptions.webSocketOptions.url, connectionOptions.webSocketOptions.protocol, connectionOptions.webSocketOptions.options); | ||
} | ||
this._connection = rhea_1.create_connection(connectionOptions); | ||
this.container = container_1.Container.copyFromContainerInstance(this._connection.container); | ||
@@ -91,3 +96,4 @@ } | ||
/** | ||
* Removes the provided session from the internal map. | ||
* Removes the provided session from the internal map in rhea. | ||
* Also removes all the event handlers added in the rhea-promise library on the provided session. | ||
* @param {Session} session The session to be removed. | ||
@@ -209,2 +215,12 @@ */ | ||
/** | ||
* Clears all the amqp sessions from the internal map maintained in rhea. This does not remove any | ||
* of the event handlers added in the rhea-promise library. To clear such event handlers, either | ||
* call remove() or close() on each session | ||
*/ | ||
removeAllSessions() { | ||
if (this._connection) { | ||
this._connection.remove_all_sessions(); | ||
} | ||
} | ||
/** | ||
* Determines whether the remote end of the connection is open. | ||
@@ -211,0 +227,0 @@ * @returns {boolean} result `true` - is open; `false` otherwise. |
@@ -160,3 +160,4 @@ "use strict"; | ||
/** | ||
* Removes the sender/receiver and it's underlying session from the internal map. | ||
* Removes the underlying amqp link and it's session from the internal map in rhea. Also removes | ||
* all the event handlers added in the rhea-promise library on the link and it's session. | ||
* @returns {void} void | ||
@@ -176,3 +177,4 @@ */ | ||
/** | ||
* Closes the amqp link. | ||
* Closes the underlying amqp link and session in rhea if open. Also removes all the event | ||
* handlers added in the rhea-promise library on the link and it's session | ||
* @return {Promise<void>} Promise<void> | ||
@@ -185,2 +187,3 @@ * - **Resolves** the promise when rhea emits the "sender_close" | "receiver_close" event. | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
this.removeAllListeners(); | ||
yield new Promise((resolve, reject) => { | ||
@@ -187,0 +190,0 @@ log.error("[%s] The %s is open ? -> %s", this.connection.id, this.type, this.isOpen()); |
@@ -65,2 +65,6 @@ "use strict"; | ||
} | ||
/** | ||
* Removes the underlying amqp session from the internal map in rhea. | ||
* Also removes all the event handlers added in the rhea-promise library on the session. | ||
*/ | ||
remove() { | ||
@@ -80,3 +84,4 @@ if (this._session) { | ||
/** | ||
* Closes the amqp session. | ||
* Closes the underlying amqp session in rhea if open. Also removes all the event | ||
* handlers added in the rhea-promise library on the session | ||
* @return {Promise<void>} Promise<void> | ||
@@ -88,2 +93,3 @@ * - **Resolves** the promise when rhea emits the "session_close" event. | ||
close() { | ||
this.removeAllListeners(); | ||
return new Promise((resolve, reject) => { | ||
@@ -90,0 +96,0 @@ log.error("[%s] The session is open ? -> %s", this.connection.id, this.isOpen()); |
@@ -14,3 +14,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
import { | ||
ConnectionEvents, SessionEvents, SenderEvents, ReceiverEvents, create_connection, | ||
ConnectionEvents, SessionEvents, SenderEvents, ReceiverEvents, create_connection, websocket_connect, | ||
ConnectionOptions as RheaConnectionOptions, Connection as RheaConnection, AmqpError, Dictionary, | ||
@@ -53,4 +53,36 @@ ConnectionError, EventContext as RheaEventContext | ||
operationTimeoutInSeconds?: number; | ||
/** | ||
* @property {Object} [webSocketOptions] - Options that include a web socket constructor along | ||
* with arguments to be passed to the function returned by rhea.websocket_connect() | ||
* This is required when the connection needs to use web sockets but is being created without | ||
* creating a container first. If a container is already available, use `websocket_connect` on it | ||
* directly instead. | ||
*/ | ||
webSocketOptions?: { | ||
/** | ||
* @property {any} [webSocket] - The WebSocket constructor used to create an AMQP | ||
* connection over a WebSocket. | ||
*/ | ||
webSocket: any; | ||
/** | ||
* @property {string} [url] - Websocket url which will be passed to the function returned by | ||
* rhea.websocket_connect() | ||
*/ | ||
url: string; | ||
/** | ||
* @property {string[]} {protocol} - Websocket SubProtocol to be passed to the function | ||
* returned by rhea.websocket_connect() | ||
*/ | ||
protocol: string[], | ||
/*** | ||
* @property {any} {options} - Options to be passed to the function returned by | ||
* rhea.websocket_connect() | ||
*/ | ||
options?: any | ||
}; | ||
} | ||
/** | ||
@@ -150,3 +182,11 @@ * Describes the options that can be provided while creating a rhea-promise connection from an | ||
} else { | ||
this._connection = create_connection(options as ConnectionOptions); | ||
const connectionOptions = options as ConnectionOptions; | ||
if (connectionOptions.webSocketOptions) { | ||
const ws = websocket_connect(connectionOptions.webSocketOptions.webSocket); | ||
(connectionOptions.connection_details as any) = ws( | ||
connectionOptions.webSocketOptions.url, | ||
connectionOptions.webSocketOptions.protocol, | ||
connectionOptions.webSocketOptions.options); | ||
} | ||
this._connection = create_connection(connectionOptions); | ||
this.container = Container.copyFromContainerInstance(this._connection.container); | ||
@@ -210,3 +250,4 @@ } | ||
/** | ||
* Removes the provided session from the internal map. | ||
* Removes the provided session from the internal map in rhea. | ||
* Also removes all the event handlers added in the rhea-promise library on the provided session. | ||
* @param {Session} session The session to be removed. | ||
@@ -344,2 +385,13 @@ */ | ||
/** | ||
* Clears all the amqp sessions from the internal map maintained in rhea. This does not remove any | ||
* of the event handlers added in the rhea-promise library. To clear such event handlers, either | ||
* call remove() or close() on each session | ||
*/ | ||
removeAllSessions(): void { | ||
if (this._connection) { | ||
this._connection.remove_all_sessions(); | ||
} | ||
} | ||
/** | ||
* Determines whether the remote end of the connection is open. | ||
@@ -346,0 +398,0 @@ * @returns {boolean} result `true` - is open; `false` otherwise. |
@@ -194,3 +194,4 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
/** | ||
* Removes the sender/receiver and it's underlying session from the internal map. | ||
* Removes the underlying amqp link and it's session from the internal map in rhea. Also removes | ||
* all the event handlers added in the rhea-promise library on the link and it's session. | ||
* @returns {void} void | ||
@@ -211,3 +212,4 @@ */ | ||
/** | ||
* Closes the amqp link. | ||
* Closes the underlying amqp link and session in rhea if open. Also removes all the event | ||
* handlers added in the rhea-promise library on the link and it's session | ||
* @return {Promise<void>} Promise<void> | ||
@@ -219,2 +221,3 @@ * - **Resolves** the promise when rhea emits the "sender_close" | "receiver_close" event. | ||
async close(): Promise<void> { | ||
this.removeAllListeners(); | ||
await new Promise<void>((resolve, reject) => { | ||
@@ -221,0 +224,0 @@ log.error("[%s] The %s is open ? -> %s", this.connection.id, this.type, this.isOpen()); |
@@ -87,2 +87,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
/** | ||
* Removes the underlying amqp session from the internal map in rhea. | ||
* Also removes all the event handlers added in the rhea-promise library on the session. | ||
*/ | ||
remove(): void { | ||
@@ -104,3 +108,4 @@ if (this._session) { | ||
/** | ||
* Closes the amqp session. | ||
* Closes the underlying amqp session in rhea if open. Also removes all the event | ||
* handlers added in the rhea-promise library on the session | ||
* @return {Promise<void>} Promise<void> | ||
@@ -112,2 +117,3 @@ * - **Resolves** the promise when rhea emits the "session_close" event. | ||
close(): Promise<void> { | ||
this.removeAllListeners(); | ||
return new Promise<void>((resolve, reject) => { | ||
@@ -114,0 +120,0 @@ log.error("[%s] The session is open ? -> %s", this.connection.id, this.isOpen()); |
{ | ||
"name": "rhea-promise", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "A Promisified layer over rhea AMQP client", | ||
@@ -10,3 +10,3 @@ "license": "Apache-2.0", | ||
"debug": "^3.1.0", | ||
"rhea": "^0.3.5", | ||
"rhea": "^1.0.2", | ||
"tslib": "^1.9.3" | ||
@@ -13,0 +13,0 @@ }, |
@@ -38,2 +38,31 @@ /// <reference types="node" /> | ||
operationTimeoutInSeconds?: number; | ||
/** | ||
* @property {Object} [webSocketOptions] - Options that include a web socket constructor along | ||
* with arguments to be passed to the function returned by rhea.websocket_connect() | ||
* This is required when the connection needs to use web sockets but is being created without | ||
* creating a container first. If a container is already available, use `websocket_connect` on it | ||
* directly instead. | ||
*/ | ||
webSocketOptions?: { | ||
/** | ||
* @property {any} [webSocket] - The WebSocket constructor used to create an AMQP | ||
* connection over a WebSocket. | ||
*/ | ||
webSocket: any; | ||
/** | ||
* @property {string} [url] - Websocket url which will be passed to the function returned by | ||
* rhea.websocket_connect() | ||
*/ | ||
url: string; | ||
/** | ||
* @property {string[]} {protocol} - Websocket SubProtocol to be passed to the function | ||
* returned by rhea.websocket_connect() | ||
*/ | ||
protocol: string[]; | ||
/*** | ||
* @property {any} {options} - Options to be passed to the function returned by | ||
* rhea.websocket_connect() | ||
*/ | ||
options?: any; | ||
}; | ||
} | ||
@@ -146,3 +175,4 @@ /** | ||
/** | ||
* Removes the provided session from the internal map. | ||
* Removes the provided session from the internal map in rhea. | ||
* Also removes all the event handlers added in the rhea-promise library on the provided session. | ||
* @param {Session} session The session to be removed. | ||
@@ -173,2 +203,8 @@ */ | ||
/** | ||
* Clears all the amqp sessions from the internal map maintained in rhea. This does not remove any | ||
* of the event handlers added in the rhea-promise library. To clear such event handlers, either | ||
* call remove() or close() on each session | ||
*/ | ||
removeAllSessions(): void; | ||
/** | ||
* Determines whether the remote end of the connection is open. | ||
@@ -175,0 +211,0 @@ * @returns {boolean} result `true` - is open; `false` otherwise. |
@@ -94,3 +94,4 @@ import { link, LinkOptions, AmqpError, Dictionary, Source, TerminusOptions } from "rhea"; | ||
/** | ||
* Removes the sender/receiver and it's underlying session from the internal map. | ||
* Removes the underlying amqp link and it's session from the internal map in rhea. Also removes | ||
* all the event handlers added in the rhea-promise library on the link and it's session. | ||
* @returns {void} void | ||
@@ -100,3 +101,4 @@ */ | ||
/** | ||
* Closes the amqp link. | ||
* Closes the underlying amqp link and session in rhea if open. Also removes all the event | ||
* handlers added in the rhea-promise library on the link and it's session | ||
* @return {Promise<void>} Promise<void> | ||
@@ -103,0 +105,0 @@ * - **Resolves** the promise when rhea emits the "sender_close" | "receiver_close" event. |
@@ -48,6 +48,11 @@ import { Connection } from "./connection"; | ||
isItselfClosed(): boolean; | ||
/** | ||
* Removes the underlying amqp session from the internal map in rhea. | ||
* Also removes all the event handlers added in the rhea-promise library on the session. | ||
*/ | ||
remove(): void; | ||
begin(): void; | ||
/** | ||
* Closes the amqp session. | ||
* Closes the underlying amqp session in rhea if open. Also removes all the event | ||
* handlers added in the rhea-promise library on the session | ||
* @return {Promise<void>} Promise<void> | ||
@@ -54,0 +59,0 @@ * - **Resolves** the promise when rhea emits the "session_close" event. |
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
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
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
265184
4566
1
+ Addedrhea@1.0.24(transitive)
- Removedrhea@0.3.11(transitive)
Updatedrhea@^1.0.2