Socket
Socket
Sign inDemoInstall

amqp-connection-manager

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqp-connection-manager - npm Package Compare versions

Comparing version 4.1.9 to 4.1.10

132

dist/cjs/ChannelWrapper.js

@@ -61,68 +61,2 @@ "use strict";

class ChannelWrapper extends events_1.EventEmitter {
/**
* Create a new ChannelWrapper.
*
* @param connectionManager - connection manager which
* created this channel.
* @param [options] -
* @param [options.name] - A name for this channel. Handy for debugging.
* @param [options.setup] - A default setup function to call. See
* `addSetup` for details.
* @param [options.json] - if true, then ChannelWrapper assumes all
* messages passed to `publish()` and `sendToQueue()` are plain JSON objects.
* These will be encoded automatically before being sent.
*
*/
constructor(connectionManager, options = {}) {
var _a, _b;
super();
/** If we're in the process of creating a channel, this is a Promise which
* will resolve when the channel is set up. Otherwise, this is `null`.
*/
this._settingUp = undefined;
/** Queued messages, not yet sent. */
this._messages = [];
/** Oublished, but not yet confirmed messages. */
this._unconfirmedMessages = [];
/** Consumers which will be reconnected on channel errors etc. */
this._consumers = [];
/**
* True to create a ConfirmChannel. False to create a regular Channel.
*/
this._confirm = true;
/**
* True if the "worker" is busy sending messages. False if we need to
* start the worker to get stuff done.
*/
this._working = false;
/**
* We kill off workers when we disconnect. Whenever we start a new
* worker, we bump up the `_workerNumber` - this makes it so if stale
* workers ever do wake up, they'll know to stop working.
*/
this._workerNumber = 0;
/**
* True if the underlying channel has room for more messages.
*/
this._channelHasRoom = true;
this._onConnect = this._onConnect.bind(this);
this._onDisconnect = this._onDisconnect.bind(this);
this._connectionManager = connectionManager;
this._confirm = (_a = options.confirm) !== null && _a !== void 0 ? _a : true;
this.name = options.name;
this._publishTimeout = options.publishTimeout;
this._json = (_b = options.json) !== null && _b !== void 0 ? _b : false;
// Array of setup functions to call.
this._setups = [];
this._consumers = [];
if (options.setup) {
this._setups.push(options.setup);
}
const connection = connectionManager.connection;
if (connection) {
this._onConnect({ connection });
}
connectionManager.on('connect', this._onConnect);
connectionManager.on('disconnect', this._onDisconnect);
}
addListener(event, listener) {

@@ -274,2 +208,68 @@ return super.addListener(event, listener);

}
/**
* Create a new ChannelWrapper.
*
* @param connectionManager - connection manager which
* created this channel.
* @param [options] -
* @param [options.name] - A name for this channel. Handy for debugging.
* @param [options.setup] - A default setup function to call. See
* `addSetup` for details.
* @param [options.json] - if true, then ChannelWrapper assumes all
* messages passed to `publish()` and `sendToQueue()` are plain JSON objects.
* These will be encoded automatically before being sent.
*
*/
constructor(connectionManager, options = {}) {
var _a, _b;
super();
/** If we're in the process of creating a channel, this is a Promise which
* will resolve when the channel is set up. Otherwise, this is `null`.
*/
this._settingUp = undefined;
/** Queued messages, not yet sent. */
this._messages = [];
/** Oublished, but not yet confirmed messages. */
this._unconfirmedMessages = [];
/** Consumers which will be reconnected on channel errors etc. */
this._consumers = [];
/**
* True to create a ConfirmChannel. False to create a regular Channel.
*/
this._confirm = true;
/**
* True if the "worker" is busy sending messages. False if we need to
* start the worker to get stuff done.
*/
this._working = false;
/**
* We kill off workers when we disconnect. Whenever we start a new
* worker, we bump up the `_workerNumber` - this makes it so if stale
* workers ever do wake up, they'll know to stop working.
*/
this._workerNumber = 0;
/**
* True if the underlying channel has room for more messages.
*/
this._channelHasRoom = true;
this._onConnect = this._onConnect.bind(this);
this._onDisconnect = this._onDisconnect.bind(this);
this._connectionManager = connectionManager;
this._confirm = (_a = options.confirm) !== null && _a !== void 0 ? _a : true;
this.name = options.name;
this._publishTimeout = options.publishTimeout;
this._json = (_b = options.json) !== null && _b !== void 0 ? _b : false;
// Array of setup functions to call.
this._setups = [];
this._consumers = [];
if (options.setup) {
this._setups.push(options.setup);
}
const connection = connectionManager.connection;
if (connection) {
this._onConnect({ connection });
}
connectionManager.on('connect', this._onConnect);
connectionManager.on('disconnect', this._onDisconnect);
}
// Called whenever we connect to the broker.

@@ -276,0 +276,0 @@ async _onConnect({ connection }) {

@@ -10,3 +10,3 @@ /// <reference types="node" />

import ChannelWrapper, { CreateChannelOpts } from './ChannelWrapper.js';
export declare type ConnectionUrl = string | amqp.Options.Connect | {
export type ConnectionUrl = string | amqp.Options.Connect | {
url: string;

@@ -27,3 +27,3 @@ connectionOptions?: AmqpConnectionOptions;

}
export declare type AmqpConnectionOptions = (ConnectionOptions | TcpSocketConnectOpts) & {
export type AmqpConnectionOptions = (ConnectionOptions | TcpSocketConnectOpts) & {
noDelay?: boolean;

@@ -30,0 +30,0 @@ timeout?: number;

@@ -8,4 +8,4 @@ /// <reference types="node" />

import { IAmqpConnectionManager } from './AmqpConnectionManager.js';
export declare type Channel = amqplib.ConfirmChannel | amqplib.Channel;
export declare type SetupFunc = ((channel: Channel, callback: (error?: Error) => void) => void) | ((channel: Channel) => Promise<void>) | ((channel: amqplib.ConfirmChannel, callback: (error?: Error) => void) => void) | ((channel: amqplib.ConfirmChannel) => Promise<void>);
export type Channel = amqplib.ConfirmChannel | amqplib.Channel;
export type SetupFunc = ((channel: Channel, callback: (error?: Error) => void) => void) | ((channel: Channel) => Promise<void>) | ((channel: amqplib.ConfirmChannel, callback: (error?: Error) => void) => void) | ((channel: amqplib.ConfirmChannel) => Promise<void>);
export interface CreateChannelOpts {

@@ -12,0 +12,0 @@ /** Name for this channel. Used for debugging. */

@@ -33,68 +33,2 @@ import * as crypto from 'crypto';

export default class ChannelWrapper extends EventEmitter {
/**
* Create a new ChannelWrapper.
*
* @param connectionManager - connection manager which
* created this channel.
* @param [options] -
* @param [options.name] - A name for this channel. Handy for debugging.
* @param [options.setup] - A default setup function to call. See
* `addSetup` for details.
* @param [options.json] - if true, then ChannelWrapper assumes all
* messages passed to `publish()` and `sendToQueue()` are plain JSON objects.
* These will be encoded automatically before being sent.
*
*/
constructor(connectionManager, options = {}) {
var _a, _b;
super();
/** If we're in the process of creating a channel, this is a Promise which
* will resolve when the channel is set up. Otherwise, this is `null`.
*/
this._settingUp = undefined;
/** Queued messages, not yet sent. */
this._messages = [];
/** Oublished, but not yet confirmed messages. */
this._unconfirmedMessages = [];
/** Consumers which will be reconnected on channel errors etc. */
this._consumers = [];
/**
* True to create a ConfirmChannel. False to create a regular Channel.
*/
this._confirm = true;
/**
* True if the "worker" is busy sending messages. False if we need to
* start the worker to get stuff done.
*/
this._working = false;
/**
* We kill off workers when we disconnect. Whenever we start a new
* worker, we bump up the `_workerNumber` - this makes it so if stale
* workers ever do wake up, they'll know to stop working.
*/
this._workerNumber = 0;
/**
* True if the underlying channel has room for more messages.
*/
this._channelHasRoom = true;
this._onConnect = this._onConnect.bind(this);
this._onDisconnect = this._onDisconnect.bind(this);
this._connectionManager = connectionManager;
this._confirm = (_a = options.confirm) !== null && _a !== void 0 ? _a : true;
this.name = options.name;
this._publishTimeout = options.publishTimeout;
this._json = (_b = options.json) !== null && _b !== void 0 ? _b : false;
// Array of setup functions to call.
this._setups = [];
this._consumers = [];
if (options.setup) {
this._setups.push(options.setup);
}
const connection = connectionManager.connection;
if (connection) {
this._onConnect({ connection });
}
connectionManager.on('connect', this._onConnect);
connectionManager.on('disconnect', this._onDisconnect);
}
addListener(event, listener) {

@@ -246,2 +180,68 @@ return super.addListener(event, listener);

}
/**
* Create a new ChannelWrapper.
*
* @param connectionManager - connection manager which
* created this channel.
* @param [options] -
* @param [options.name] - A name for this channel. Handy for debugging.
* @param [options.setup] - A default setup function to call. See
* `addSetup` for details.
* @param [options.json] - if true, then ChannelWrapper assumes all
* messages passed to `publish()` and `sendToQueue()` are plain JSON objects.
* These will be encoded automatically before being sent.
*
*/
constructor(connectionManager, options = {}) {
var _a, _b;
super();
/** If we're in the process of creating a channel, this is a Promise which
* will resolve when the channel is set up. Otherwise, this is `null`.
*/
this._settingUp = undefined;
/** Queued messages, not yet sent. */
this._messages = [];
/** Oublished, but not yet confirmed messages. */
this._unconfirmedMessages = [];
/** Consumers which will be reconnected on channel errors etc. */
this._consumers = [];
/**
* True to create a ConfirmChannel. False to create a regular Channel.
*/
this._confirm = true;
/**
* True if the "worker" is busy sending messages. False if we need to
* start the worker to get stuff done.
*/
this._working = false;
/**
* We kill off workers when we disconnect. Whenever we start a new
* worker, we bump up the `_workerNumber` - this makes it so if stale
* workers ever do wake up, they'll know to stop working.
*/
this._workerNumber = 0;
/**
* True if the underlying channel has room for more messages.
*/
this._channelHasRoom = true;
this._onConnect = this._onConnect.bind(this);
this._onDisconnect = this._onDisconnect.bind(this);
this._connectionManager = connectionManager;
this._confirm = (_a = options.confirm) !== null && _a !== void 0 ? _a : true;
this.name = options.name;
this._publishTimeout = options.publishTimeout;
this._json = (_b = options.json) !== null && _b !== void 0 ? _b : false;
// Array of setup functions to call.
this._setups = [];
this._consumers = [];
if (options.setup) {
this._setups.push(options.setup);
}
const connection = connectionManager.connection;
if (connection) {
this._onConnect({ connection });
}
connectionManager.on('connect', this._onConnect);
connectionManager.on('disconnect', this._onDisconnect);
}
// Called whenever we connect to the broker.

@@ -248,0 +248,0 @@ async _onConnect({ connection }) {

import AmqpConnectionManager, { AmqpConnectionManagerOptions, ConnectionUrl, IAmqpConnectionManager } from './AmqpConnectionManager.js';
import { PublishOptions } from './ChannelWrapper.js';
import CW, { PublishOptions } from './ChannelWrapper.js';
export type { AmqpConnectionManagerOptions, ConnectionUrl, IAmqpConnectionManager as AmqpConnectionManager, } from './AmqpConnectionManager.js';
export type { CreateChannelOpts, default as ChannelWrapper, SetupFunc, Channel, } from './ChannelWrapper.js';
export type { CreateChannelOpts, SetupFunc, Channel } from './ChannelWrapper.js';
export type ChannelWrapper = CW;
import { Options as AmqpLibOptions } from 'amqplib';

@@ -6,0 +7,0 @@ export declare namespace Options {

{
"name": "amqp-connection-manager",
"version": "4.1.9",
"version": "4.1.10",
"description": "Auto-reconnect and round robin support for amqplib.",

@@ -28,3 +28,3 @@ "module": "./dist/esm/index.js",

"@semantic-release/git": "^10.0.1",
"@types/amqplib": "^0.8.2",
"@types/amqplib": "^0.10.0",
"@types/chai": "^4.2.21",

@@ -31,0 +31,0 @@ "@types/chai-as-promised": "^7.1.4",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc