rhea-promise
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -0,1 +1,5 @@ | ||
### 0.1.3 - 2018-09-25 | ||
- Transform relevant objects in rhea EventContext to rhea-promise objects. | ||
- Ensure that `container.createConnection()` creates a connection on that container and not on the default container. | ||
### 0.1.2 - 2018-09-20 | ||
@@ -2,0 +6,0 @@ - TS target to ES2015. This should help us support node.js version 6.x and above. |
@@ -12,2 +12,7 @@ "use strict"; | ||
const rhea_1 = require("rhea"); | ||
const eventContext_1 = require("./eventContext"); | ||
// Determines whether the given object is a CreatedRheConnectionOptions object. | ||
function isCreatedRheaConnectionOptions(obj) { | ||
return (obj && typeof obj.container === "object" && typeof obj.rheaConnection === "object"); | ||
} | ||
/** | ||
@@ -24,2 +29,3 @@ * Descibes the AQMP Connection. | ||
constructor(options) { | ||
super(); | ||
if (!options) | ||
@@ -30,6 +36,13 @@ options = {}; | ||
} | ||
super(); | ||
this.options = options; | ||
this._connection = rhea_1.create_connection(options); | ||
this.container = container_1.Container.copyFromContainerInstance(this._connection.container); | ||
if (isCreatedRheaConnectionOptions(options)) { | ||
this._connection = options.rheaConnection; | ||
this.container = options.container; | ||
this.options = this._connection.options; | ||
this.options.operationTimeoutInSeconds = options.operationTimeoutInSeconds; | ||
} | ||
else { | ||
this.options = options; | ||
this._connection = rhea_1.create_connection(options); | ||
this.container = container_1.Container.copyFromContainerInstance(this._connection.container); | ||
} | ||
this._initializeEventListeners(); | ||
@@ -344,3 +357,3 @@ } | ||
for (const eventName in rhea_1.ConnectionEvents) { | ||
this._connection.on(rhea_1.ConnectionEvents[eventName], (...args) => this.emit(rhea_1.ConnectionEvents[eventName], ...args)); | ||
this._connection.on(rhea_1.ConnectionEvents[eventName], (context) => this.emit(rhea_1.ConnectionEvents[eventName], eventContext_1.EventContext.translate(context, this))); | ||
} | ||
@@ -350,10 +363,10 @@ // Add event handlers for *_error and *_close events that can be propogated to the connection | ||
// Sender | ||
this._connection.on(rhea_1.SenderEvents.senderError, (...args) => this.emit(rhea_1.SenderEvents.senderError, ...args)); | ||
this._connection.on(rhea_1.SenderEvents.senderClose, (...args) => this.emit(rhea_1.SenderEvents.senderClose, ...args)); | ||
this._connection.on(rhea_1.SenderEvents.senderError, (context) => this.emit(rhea_1.SenderEvents.senderError, eventContext_1.EventContext.translate(context, this))); | ||
this._connection.on(rhea_1.SenderEvents.senderClose, (context) => this.emit(rhea_1.SenderEvents.senderClose, eventContext_1.EventContext.translate(context, this))); | ||
// Receiver | ||
this._connection.on(rhea_1.ReceiverEvents.receiverError, (...args) => this.emit(rhea_1.ReceiverEvents.receiverError, ...args)); | ||
this._connection.on(rhea_1.ReceiverEvents.receiverClose, (...args) => this.emit(rhea_1.ReceiverEvents.receiverClose, ...args)); | ||
this._connection.on(rhea_1.ReceiverEvents.receiverError, (context) => this.emit(rhea_1.ReceiverEvents.receiverError, eventContext_1.EventContext.translate(context, this))); | ||
this._connection.on(rhea_1.ReceiverEvents.receiverClose, (context) => this.emit(rhea_1.ReceiverEvents.receiverClose, eventContext_1.EventContext.translate(context, this))); | ||
// Session | ||
this._connection.on(rhea_1.SessionEvents.sessionError, (...args) => this.emit(rhea_1.SessionEvents.sessionError, ...args)); | ||
this._connection.on(rhea_1.SessionEvents.sessionClose, (...args) => this.emit(rhea_1.SessionEvents.sessionClose, ...args)); | ||
this._connection.on(rhea_1.SessionEvents.sessionError, (context) => this.emit(rhea_1.SessionEvents.sessionError, eventContext_1.EventContext.translate(context, this))); | ||
this._connection.on(rhea_1.SessionEvents.sessionClose, (context) => this.emit(rhea_1.SessionEvents.sessionClose, eventContext_1.EventContext.translate(context, this))); | ||
} | ||
@@ -360,0 +373,0 @@ } |
@@ -5,2 +5,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const rhea_1 = require("rhea"); | ||
@@ -47,4 +48,10 @@ const events_1 = require("events"); | ||
createConnection(options) { | ||
return new connection_1.Connection(options); | ||
const rheaConnection = this._container.create_connection(options); | ||
return new connection_1.Connection({ rheaConnection: rheaConnection, container: this }); | ||
} | ||
connect(options) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return yield this.createConnection(options).open(); | ||
}); | ||
} | ||
listen(options) { | ||
@@ -51,0 +58,0 @@ return this._container.listen(options); |
@@ -16,2 +16,4 @@ "use strict"; | ||
exports.SessionEvents = rhea_1.SessionEvents; | ||
var eventContext_1 = require("./eventContext"); | ||
exports.EventContext = eventContext_1.EventContext; | ||
var container_1 = require("./container"); | ||
@@ -18,0 +20,0 @@ exports.Container = container_1.Container; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const events_1 = require("events"); | ||
const eventContext_1 = require("./eventContext"); | ||
var LinkType; | ||
@@ -240,3 +241,3 @@ (function (LinkType) { | ||
for (const eventName in events) { | ||
this._link.on(events[eventName], (...args) => this.emit(events[eventName], ...args)); | ||
this._link.on(events[eventName], (context) => this.emit(events[eventName], eventContext_1.EventContext.translate(context, this))); | ||
} | ||
@@ -243,0 +244,0 @@ } |
@@ -11,2 +11,3 @@ "use strict"; | ||
const events_1 = require("events"); | ||
const eventContext_1 = require("./eventContext"); | ||
/** | ||
@@ -33,2 +34,5 @@ * Describes the session that wraps the rhea session. | ||
} | ||
get error() { | ||
return this._session.error; | ||
} | ||
/** | ||
@@ -275,3 +279,3 @@ * Determines whether the session and the underlying connection is open. | ||
for (const eventName in rhea_1.SessionEvents) { | ||
this._session.on(rhea_1.SessionEvents[eventName], (...args) => this.emit(rhea_1.SessionEvents[eventName], ...args)); | ||
this._session.on(rhea_1.SessionEvents[eventName], (context) => this.emit(rhea_1.SessionEvents[eventName], eventContext_1.EventContext.translate(context, this))); | ||
} | ||
@@ -281,7 +285,7 @@ // Add event handlers for *_error and *_close events that can be propogated to the session | ||
// Sender | ||
this._session.on(rhea.SenderEvents.senderError, (...args) => this.emit(rhea.SenderEvents.senderError, ...args)); | ||
this._session.on(rhea.SenderEvents.senderClose, (...args) => this.emit(rhea.SenderEvents.senderClose, ...args)); | ||
this._session.on(rhea.SenderEvents.senderError, (context) => this.emit(rhea.SenderEvents.senderError, eventContext_1.EventContext.translate(context, this))); | ||
this._session.on(rhea.SenderEvents.senderClose, (context) => this.emit(rhea.SenderEvents.senderClose, eventContext_1.EventContext.translate(context, this))); | ||
// Receiver | ||
this._session.on(rhea.ReceiverEvents.receiverError, (...args) => this.emit(rhea.ReceiverEvents.receiverError, ...args)); | ||
this._session.on(rhea.ReceiverEvents.receiverClose, (...args) => this.emit(rhea.ReceiverEvents.receiverClose, ...args)); | ||
this._session.on(rhea.ReceiverEvents.receiverError, (context) => this.emit(rhea.ReceiverEvents.receiverError, eventContext_1.EventContext.translate(context, this))); | ||
this._session.on(rhea.ReceiverEvents.receiverClose, (context) => this.emit(rhea.ReceiverEvents.receiverClose, eventContext_1.EventContext.translate(context, this))); | ||
} | ||
@@ -288,0 +292,0 @@ } |
@@ -15,7 +15,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
import { | ||
ConnectionEvents, SessionEvents, SenderEvents, ReceiverEvents, OnAmqpEvent, create_connection, | ||
ConnectionOptions as RheaConnectionOptions, Connection as RheaConnection, EventContext, | ||
ConnectionError, Dictionary, AmqpError | ||
ConnectionEvents, SessionEvents, SenderEvents, ReceiverEvents, create_connection, | ||
ConnectionOptions as RheaConnectionOptions, Connection as RheaConnection, AmqpError, Dictionary, | ||
ConnectionError, EventContext as RheaEventContext | ||
} from "rhea"; | ||
import { EventContext, OnAmqpEvent } from "./eventContext"; | ||
/** | ||
@@ -51,3 +53,31 @@ * Describes the options that can be provided while creating an AMQP sender. One can also provide a | ||
} | ||
/** | ||
* Describes the options that can be provided while creating a rhea-promise connection from an | ||
* already created rhea connection object. | ||
* @interface CreatedRheaConnectionOptions | ||
*/ | ||
export interface CreatedRheaConnectionOptions { | ||
/** | ||
* @property {number} [operationTimeoutInSeconds] - The duration in which the promise should | ||
* complete (resolve/reject). If it is not completed, then the Promise will be rejected after | ||
* timeout occurs. Default: `60 seconds`. | ||
*/ | ||
operationTimeoutInSeconds?: number; | ||
/** | ||
* @property rheaConnection The connection object from rhea | ||
*/ | ||
rheaConnection: RheaConnection; | ||
/** | ||
* @property container The Container object from this (rhea-promise) library. | ||
*/ | ||
container: Container; | ||
} | ||
// Determines whether the given object is a CreatedRheConnectionOptions object. | ||
function isCreatedRheaConnectionOptions(obj: any): boolean { | ||
return (obj && typeof obj.container === "object" && typeof obj.rheaConnection === "object"); | ||
} | ||
/** | ||
* Provides a sender and a receiver link on the same session. It is useful while constructing a | ||
@@ -107,3 +137,4 @@ * request/response link. | ||
*/ | ||
constructor(options?: ConnectionOptions) { | ||
constructor(options?: ConnectionOptions | CreatedRheaConnectionOptions) { | ||
super(); | ||
if (!options) options = {}; | ||
@@ -113,6 +144,14 @@ if (options.operationTimeoutInSeconds == undefined) { | ||
} | ||
super(); | ||
this.options = options; | ||
this._connection = create_connection(options); | ||
this.container = Container.copyFromContainerInstance(this._connection.container); | ||
if (isCreatedRheaConnectionOptions(options)) { | ||
this._connection = (options as CreatedRheaConnectionOptions).rheaConnection; | ||
this.container = (options as CreatedRheaConnectionOptions).container; | ||
this.options = this._connection.options; | ||
this.options.operationTimeoutInSeconds = options.operationTimeoutInSeconds; | ||
} else { | ||
this.options = options; | ||
this._connection = create_connection(options as ConnectionOptions); | ||
this.container = Container.copyFromContainerInstance(this._connection.container); | ||
} | ||
this._initializeEventListeners(); | ||
@@ -188,4 +227,4 @@ } | ||
let onOpen: Func<EventContext, void>; | ||
let onClose: Func<EventContext, void>; | ||
let onOpen: Func<RheaEventContext, void>; | ||
let onClose: Func<RheaEventContext, void>; | ||
let waitTimer: any; | ||
@@ -200,3 +239,3 @@ | ||
onOpen = (context: EventContext) => { | ||
onOpen = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -209,3 +248,3 @@ setTimeout(() => { | ||
onClose = (context: EventContext) => { | ||
onClose = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -250,4 +289,4 @@ const err = context.error || context.connection.error; | ||
if (this.isOpen()) { | ||
let onClose: Func<EventContext, void>; | ||
let onError: Func<EventContext, void>; | ||
let onClose: Func<RheaEventContext, void>; | ||
let onError: Func<RheaEventContext, void>; | ||
let waitTimer: any; | ||
@@ -260,3 +299,3 @@ const removeListeners = () => { | ||
onClose = (context: EventContext) => { | ||
onClose = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -270,3 +309,3 @@ setTimeout(() => { | ||
onError = (context: EventContext) => { | ||
onError = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -360,4 +399,4 @@ log.error("[%s] Error occurred while closing amqp connection: %O.", | ||
const session = new Session(this, rheaSession); | ||
let onOpen: Func<EventContext, void>; | ||
let onClose: Func<EventContext, void>; | ||
let onOpen: Func<RheaEventContext, void>; | ||
let onClose: Func<RheaEventContext, void>; | ||
let waitTimer: any; | ||
@@ -371,3 +410,3 @@ | ||
onOpen = (context: EventContext) => { | ||
onOpen = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -380,3 +419,3 @@ setTimeout(() => { | ||
onClose = (context: EventContext) => { | ||
onClose = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -469,3 +508,3 @@ log.error("[%s] Error occurred while establishing a session over amqp connection: %O.", | ||
this._connection.on(ConnectionEvents[eventName], | ||
(...args) => this.emit(ConnectionEvents[eventName], ...args)); | ||
(context) => this.emit(ConnectionEvents[eventName], EventContext.translate(context, this))); | ||
} | ||
@@ -477,16 +516,17 @@ | ||
this._connection.on(SenderEvents.senderError, | ||
(...args) => this.emit(SenderEvents.senderError, ...args)); | ||
(context) => this.emit(SenderEvents.senderError, EventContext.translate(context, this))); | ||
this._connection.on(SenderEvents.senderClose, | ||
(...args) => this.emit(SenderEvents.senderClose, ...args)); | ||
(context) => this.emit(SenderEvents.senderClose, EventContext.translate(context, this))); | ||
// Receiver | ||
this._connection.on(ReceiverEvents.receiverError, | ||
(...args) => this.emit(ReceiverEvents.receiverError, ...args)); | ||
(context) => this.emit(ReceiverEvents.receiverError, EventContext.translate(context, this))); | ||
this._connection.on(ReceiverEvents.receiverClose, | ||
(...args) => this.emit(ReceiverEvents.receiverClose, ...args)); | ||
(context) => this.emit(ReceiverEvents.receiverClose, EventContext.translate(context, this))); | ||
// Session | ||
this._connection.on(SessionEvents.sessionError, | ||
(...args) => this.emit(SessionEvents.sessionError, ...args)); | ||
(context) => this.emit(SessionEvents.sessionError, EventContext.translate(context, this))); | ||
this._connection.on(SessionEvents.sessionClose, | ||
(...args) => this.emit(SessionEvents.sessionClose, ...args)); | ||
(context) => this.emit(SessionEvents.sessionClose, EventContext.translate(context, this))); | ||
} | ||
} | ||
@@ -75,5 +75,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
createConnection(options?: ConnectionOptions): Connection { | ||
return new Connection(options); | ||
const rheaConnection = this._container.create_connection(options); | ||
return new Connection({ rheaConnection: rheaConnection, container: this }); | ||
} | ||
async connect(options?: ConnectionOptions): Promise<Connection> { | ||
return await this.createConnection(options).open(); | ||
} | ||
listen(options: ListenOptions | TlsOptions): Server | TlsServer { | ||
@@ -80,0 +85,0 @@ return this._container.listen(options); |
@@ -5,3 +5,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
export { | ||
Delivery, Message, OnAmqpEvent, MessageProperties, MessageHeader, EventContext, | ||
Delivery, Message, MessageProperties, MessageHeader, EventContext as RheaEventContext, | ||
ConnectionOptions as ConnectionOptionsBase, AmqpError, Dictionary, types, message, filter, Filter, | ||
@@ -14,2 +14,3 @@ uuid_to_string, generate_uuid, string_to_uuid, LinkError, ProtocolError, LinkOptions, | ||
export { EventContext, OnAmqpEvent } from "./eventContext"; | ||
export { Container, ContainerOptions } from "./container"; | ||
@@ -16,0 +17,0 @@ export { |
@@ -5,3 +5,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
import * as log from "./log"; | ||
import { link, LinkOptions, AmqpError, Dictionary, Source, TerminusOptions, EventContext, SenderEvents, ReceiverEvents } from "rhea"; | ||
import { | ||
link, LinkOptions, AmqpError, Dictionary, Source, TerminusOptions, SenderEvents, ReceiverEvents, | ||
EventContext as RheaEventContext | ||
} from "rhea"; | ||
import { EventEmitter } from "events"; | ||
@@ -11,2 +14,3 @@ import { Session } from "./session"; | ||
import { Func } from './util/utils'; | ||
import { EventContext } from "./eventContext"; | ||
@@ -224,4 +228,4 @@ export enum LinkType { | ||
: ReceiverEvents.receiverClose; | ||
let onError: Func<EventContext, void>; | ||
let onClose: Func<EventContext, void>; | ||
let onError: Func<RheaEventContext, void>; | ||
let onClose: Func<RheaEventContext, void>; | ||
let waitTimer: any; | ||
@@ -235,3 +239,3 @@ | ||
onClose = (context: EventContext) => { | ||
onClose = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -245,3 +249,3 @@ setTimeout(() => { | ||
onError = (context: EventContext) => { | ||
onError = (context: RheaEventContext) => { | ||
removeListeners(); | ||
@@ -285,5 +289,5 @@ log.error("[%s] Error occurred while closing amqp %s: %O.", | ||
this._link.on(events[eventName], | ||
(...args) => this.emit(events[eventName], ...args)); | ||
(context: RheaEventContext) => this.emit(events[eventName], EventContext.translate(context, this))); | ||
} | ||
} | ||
} |
@@ -5,8 +5,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
import * as rhea from "rhea"; | ||
import { Session } from "./session"; | ||
import { ReceiverEvents, Receiver as RheaReceiver } from "rhea"; | ||
import { Link, LinkType } from "./link"; | ||
import { OnAmqpEvent } from "./eventContext"; | ||
@@ -19,26 +17,26 @@ /** | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onMessage] The handler that can be provided for receiving the | ||
* @property {OnAmqpEvent} [onMessage] The handler that can be provided for receiving the | ||
* "message" event when a message is received on the underling rhea receiver. | ||
*/ | ||
onMessage?: rhea.OnAmqpEvent; | ||
onMessage?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onError] The handler that can be provided for receiving any | ||
* @property {OnAmqpEvent} [onError] The handler that can be provided for receiving any | ||
* errors that occur on the "receiver_error" event on the underlying rhea receiver. | ||
*/ | ||
onError?: rhea.OnAmqpEvent; | ||
onError?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onClose] The handler that can be provided for receiving the | ||
* @property {OnAmqpEvent} [onClose] The handler that can be provided for receiving the | ||
* "receiver_close" event on the underlying rhea receiver. | ||
*/ | ||
onClose?: rhea.OnAmqpEvent; | ||
onClose?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onSessionError] The handler that can be provided for receiving | ||
* @property {OnAmqpEvent} [onSessionError] The handler that can be provided for receiving | ||
* the "session_error" event that occurs on the underlying rhea session. | ||
*/ | ||
onSessionError?: rhea.OnAmqpEvent; | ||
onSessionError?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onSessionClose] The handler that can be provided for receiving the | ||
* @property {OnAmqpEvent} [onSessionClose] The handler that can be provided for receiving the | ||
* "session_close" event that occurs on the underlying rhea session. | ||
*/ | ||
onSessionClose?: rhea.OnAmqpEvent; | ||
onSessionClose?: OnAmqpEvent; | ||
} | ||
@@ -51,3 +49,3 @@ | ||
export declare interface Receiver { | ||
on(event: ReceiverEvents, listener: rhea.OnAmqpEvent): this; | ||
on(event: ReceiverEvents, listener: OnAmqpEvent): this; | ||
} | ||
@@ -54,0 +52,0 @@ |
@@ -5,3 +5,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
import { | ||
SenderOptions as RheaSenderOptions, OnAmqpEvent, Delivery, Message, Sender as RheaSender | ||
SenderOptions as RheaSenderOptions, Delivery, Message, Sender as RheaSender | ||
} from "rhea"; | ||
@@ -11,2 +11,3 @@ import { Session } from "./session"; | ||
import { Link, LinkType } from './link'; | ||
import { OnAmqpEvent } from "./eventContext"; | ||
@@ -13,0 +14,0 @@ /** |
@@ -9,5 +9,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
import { Sender, SenderOptions } from "./sender"; | ||
import { SenderEvents, ReceiverEvents, SessionEvents } from "rhea"; | ||
import { SenderEvents, ReceiverEvents, SessionEvents, AmqpError } from "rhea"; | ||
import { Func } from "./util/utils"; | ||
import { EventEmitter } from "events"; | ||
import { EventContext, OnAmqpEvent } from './eventContext'; | ||
@@ -19,3 +20,3 @@ /** | ||
export declare interface Session { | ||
on(event: SessionEvents, listener: rhea.OnAmqpEvent): this; | ||
on(event: SessionEvents, listener: OnAmqpEvent): this; | ||
} | ||
@@ -49,2 +50,6 @@ | ||
get error(): AmqpError | Error | undefined { | ||
return this._session.error; | ||
} | ||
/** | ||
@@ -328,3 +333,3 @@ * Determines whether the session and the underlying connection is open. | ||
this._session.on(SessionEvents[eventName], | ||
(...args) => this.emit(SessionEvents[eventName], ...args)); | ||
(context) => this.emit(SessionEvents[eventName], EventContext.translate(context, this))); | ||
} | ||
@@ -336,11 +341,11 @@ | ||
this._session.on(rhea.SenderEvents.senderError, | ||
(...args) => this.emit(rhea.SenderEvents.senderError, ...args)); | ||
(context) => this.emit(rhea.SenderEvents.senderError, EventContext.translate(context, this))); | ||
this._session.on(rhea.SenderEvents.senderClose, | ||
(...args) => this.emit(rhea.SenderEvents.senderClose, ...args)); | ||
(context) => this.emit(rhea.SenderEvents.senderClose, EventContext.translate(context, this))); | ||
// Receiver | ||
this._session.on(rhea.ReceiverEvents.receiverError, | ||
(...args) => this.emit(rhea.ReceiverEvents.receiverError, ...args)); | ||
(context) => this.emit(rhea.ReceiverEvents.receiverError, EventContext.translate(context, this))); | ||
this._session.on(rhea.ReceiverEvents.receiverClose, | ||
(...args) => this.emit(rhea.ReceiverEvents.receiverClose, ...args)); | ||
(context) => this.emit(rhea.ReceiverEvents.receiverClose, EventContext.translate(context, this))); | ||
} | ||
} |
{ | ||
"name": "rhea-promise", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A Promisified layer over rhea AMQP client", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -6,3 +6,5 @@ # rhea-promise | ||
## Pre-requisite ## | ||
- **Node.js version: 6.x or higher.** We would encourage you to install the latest available LTS version at any given time from https://nodejs.org. Please **do not** use older LTS versions of node.js. | ||
- **Node.js version: 6.x or higher.** | ||
- We would **still encourage you** to install the latest available LTS version at any given time from https://nodejs.org. **It is a good practice to always install the latest available LTS version of node.js.** | ||
- Installing node.js on **Windows or macOS** is very simple with available installers on the [node.js website](https://nodejs.org). If you are using a **linux based OS**, then you can find easy to follow, one step installation instructions over [here](https://nodejs.org/en/download/package-manager/). | ||
@@ -9,0 +11,0 @@ ## Installation ## |
@@ -9,3 +9,4 @@ /// <reference types="node" /> | ||
import { Container } from "./container"; | ||
import { ConnectionEvents, OnAmqpEvent, ConnectionOptions as RheaConnectionOptions, ConnectionError, Dictionary, AmqpError } from "rhea"; | ||
import { ConnectionEvents, ConnectionOptions as RheaConnectionOptions, Connection as RheaConnection, AmqpError, Dictionary, ConnectionError } from "rhea"; | ||
import { OnAmqpEvent } from "./eventContext"; | ||
/** | ||
@@ -40,2 +41,23 @@ * Describes the options that can be provided while creating an AMQP sender. One can also provide a | ||
/** | ||
* Describes the options that can be provided while creating a rhea-promise connection from an | ||
* already created rhea connection object. | ||
* @interface CreatedRheaConnectionOptions | ||
*/ | ||
export interface CreatedRheaConnectionOptions { | ||
/** | ||
* @property {number} [operationTimeoutInSeconds] - The duration in which the promise should | ||
* complete (resolve/reject). If it is not completed, then the Promise will be rejected after | ||
* timeout occurs. Default: `60 seconds`. | ||
*/ | ||
operationTimeoutInSeconds?: number; | ||
/** | ||
* @property rheaConnection The connection object from rhea | ||
*/ | ||
rheaConnection: RheaConnection; | ||
/** | ||
* @property container The Container object from this (rhea-promise) library. | ||
*/ | ||
container: Container; | ||
} | ||
/** | ||
* Provides a sender and a receiver link on the same session. It is useful while constructing a | ||
@@ -92,3 +114,3 @@ * request/response link. | ||
*/ | ||
constructor(options?: ConnectionOptions); | ||
constructor(options?: ConnectionOptions | CreatedRheaConnectionOptions); | ||
/** | ||
@@ -95,0 +117,0 @@ * @property {string} id Returns the connection id. |
@@ -37,2 +37,3 @@ /// <reference types="node" /> | ||
createConnection(options?: ConnectionOptions): Connection; | ||
connect(options?: ConnectionOptions): Promise<Connection>; | ||
listen(options: ListenOptions | TlsOptions): Server | TlsServer; | ||
@@ -39,0 +40,0 @@ generateUUid(): string; |
@@ -1,2 +0,3 @@ | ||
export { Delivery, Message, OnAmqpEvent, MessageProperties, MessageHeader, EventContext, ConnectionOptions as ConnectionOptionsBase, AmqpError, Dictionary, types, message, filter, Filter, uuid_to_string, generate_uuid, string_to_uuid, LinkError, ProtocolError, LinkOptions, DeliveryAnnotations, MessageAnnotations, ReceiverEvents, SenderEvents, ConnectionEvents, SessionEvents, ContainerOptions as ContainerOptionsBase, TerminusOptions, Types, Sasl, EndpointOptions, MessageUtil, TypeError, SimpleError, Source, ConnectionError } from "rhea"; | ||
export { Delivery, Message, MessageProperties, MessageHeader, EventContext as RheaEventContext, ConnectionOptions as ConnectionOptionsBase, AmqpError, Dictionary, types, message, filter, Filter, uuid_to_string, generate_uuid, string_to_uuid, LinkError, ProtocolError, LinkOptions, DeliveryAnnotations, MessageAnnotations, ReceiverEvents, SenderEvents, ConnectionEvents, SessionEvents, ContainerOptions as ContainerOptionsBase, TerminusOptions, Types, Sasl, EndpointOptions, MessageUtil, TypeError, SimpleError, Source, ConnectionError } from "rhea"; | ||
export { EventContext, OnAmqpEvent } from "./eventContext"; | ||
export { Container, ContainerOptions } from "./container"; | ||
@@ -3,0 +4,0 @@ export { Connection, ReqResLink, ConnectionOptions, ReceiverOptionsWithSession, SenderOptionsWithSession } from "./connection"; |
@@ -5,2 +5,3 @@ import * as rhea from "rhea"; | ||
import { Link } from "./link"; | ||
import { OnAmqpEvent } from "./eventContext"; | ||
/** | ||
@@ -12,26 +13,26 @@ * Descibes the options that can be provided while creating an AMQP sender. | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onMessage] The handler that can be provided for receiving the | ||
* @property {OnAmqpEvent} [onMessage] The handler that can be provided for receiving the | ||
* "message" event when a message is received on the underling rhea receiver. | ||
*/ | ||
onMessage?: rhea.OnAmqpEvent; | ||
onMessage?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onError] The handler that can be provided for receiving any | ||
* @property {OnAmqpEvent} [onError] The handler that can be provided for receiving any | ||
* errors that occur on the "receiver_error" event on the underlying rhea receiver. | ||
*/ | ||
onError?: rhea.OnAmqpEvent; | ||
onError?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onClose] The handler that can be provided for receiving the | ||
* @property {OnAmqpEvent} [onClose] The handler that can be provided for receiving the | ||
* "receiver_close" event on the underlying rhea receiver. | ||
*/ | ||
onClose?: rhea.OnAmqpEvent; | ||
onClose?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onSessionError] The handler that can be provided for receiving | ||
* @property {OnAmqpEvent} [onSessionError] The handler that can be provided for receiving | ||
* the "session_error" event that occurs on the underlying rhea session. | ||
*/ | ||
onSessionError?: rhea.OnAmqpEvent; | ||
onSessionError?: OnAmqpEvent; | ||
/** | ||
* @property {rhea.OnAmqpEvent} [onSessionClose] The handler that can be provided for receiving the | ||
* @property {OnAmqpEvent} [onSessionClose] The handler that can be provided for receiving the | ||
* "session_close" event that occurs on the underlying rhea session. | ||
*/ | ||
onSessionClose?: rhea.OnAmqpEvent; | ||
onSessionClose?: OnAmqpEvent; | ||
} | ||
@@ -43,3 +44,3 @@ /** | ||
export declare interface Receiver { | ||
on(event: ReceiverEvents, listener: rhea.OnAmqpEvent): this; | ||
on(event: ReceiverEvents, listener: OnAmqpEvent): this; | ||
} | ||
@@ -46,0 +47,0 @@ /** |
/// <reference types="node" /> | ||
import { SenderOptions as RheaSenderOptions, OnAmqpEvent, Delivery, Message, Sender as RheaSender } from "rhea"; | ||
import { SenderOptions as RheaSenderOptions, Delivery, Message, Sender as RheaSender } from "rhea"; | ||
import { Session } from "./session"; | ||
import { SenderEvents } from "rhea"; | ||
import { Link } from './link'; | ||
import { OnAmqpEvent } from "./eventContext"; | ||
/** | ||
@@ -7,0 +8,0 @@ * Descibes the options that can be provided while creating an AMQP sender. |
@@ -6,4 +6,5 @@ /// <reference types="node" /> | ||
import { Sender, SenderOptions } from "./sender"; | ||
import { SessionEvents } from "rhea"; | ||
import { SessionEvents, AmqpError } from "rhea"; | ||
import { EventEmitter } from "events"; | ||
import { OnAmqpEvent } from './eventContext'; | ||
/** | ||
@@ -14,3 +15,3 @@ * Describes the event listeners that can be added to the Session. | ||
export declare interface Session { | ||
on(event: SessionEvents, listener: rhea.OnAmqpEvent): this; | ||
on(event: SessionEvents, listener: OnAmqpEvent): this; | ||
} | ||
@@ -31,2 +32,3 @@ /** | ||
readonly outgoing: any; | ||
readonly error: AmqpError | Error | undefined; | ||
/** | ||
@@ -33,0 +35,0 @@ * Determines whether the session and the underlying connection is open. |
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
211846
52
3838
221