New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-nats-streaming-buffered-client

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-nats-streaming-buffered-client - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

32

dist/node-nats-streaming-buffered-client.js

@@ -52,9 +52,12 @@ "use strict";

* @param {number} [bufferSize=10] The ring buffer size
* @param {boolean} [waitForInitialConnect=false] Indicates the client can publish even before connecting. Will also change behaviour of the connect call
* @memberof NatsBufferedClient
*/
function NatsBufferedClient(bufferSize, reconnectTimeout) {
function NatsBufferedClient(bufferSize, reconnectTimeout, waitForInitialConnection) {
if (bufferSize === void 0) { bufferSize = 10; }
if (reconnectTimeout === void 0) { reconnectTimeout = 30000; }
if (waitForInitialConnection === void 0) { waitForInitialConnection = false; }
var _this = this;
this.reconnectTimeout = reconnectTimeout;
this.waitForInitialConnection = waitForInitialConnection;
/**

@@ -74,2 +77,9 @@ * Indicates if we're processing the buffer

this.clientConnected = false;
/**
* Indicator we've reached a connected state at least once with the current stan instance
*
* @private
* @memberof NatsBufferedClient
*/
this.initialConnected = false;
// Initialize our ring buffer with the requested size

@@ -173,3 +183,4 @@ //

NatsBufferedClient.prototype.connect = function (clusterId, clientId, options) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var error_3;

@@ -208,8 +219,17 @@ var _this = this;

_this.connected = true;
_this.initialConnected = true;
// Start processing the buffer
//
_this.tick();
// Resolve initial connection promise
//
resolve(true);
});
this.stan.on('error', function (error) {
console.error('[NATS-BUFFERED-CLIENT] Server error', error);
// Reject initial connection promise
//
if (!_this.initialConnected) {
reject(error);
}
});

@@ -228,3 +248,3 @@ this.stan.on('reconnecting', function () {

});
});
}); });
};

@@ -277,2 +297,8 @@ /**

NatsBufferedClient.prototype.publish = function (subject, data) {
// Don't allow publishing before initial connect if the client is
// configured to do so
//
if (this.waitForInitialConnection && !this.initialConnected) {
throw new Error('Tried to publish before initial connection');
}
// Push onto the end of the buffer

@@ -279,0 +305,0 @@ //

@@ -10,2 +10,3 @@ import * as nats from 'node-nats-streaming';

private reconnectTimeout;
private waitForInitialConnection;
/**

@@ -66,2 +67,9 @@ * The connection to the NATS server

/**
* Indicator we've reached a connected state at least once with the current stan instance
*
* @private
* @memberof NatsBufferedClient
*/
private initialConnected;
/**
* The reconnect timer

@@ -92,5 +100,6 @@ *

* @param {number} [bufferSize=10] The ring buffer size
* @param {boolean} [waitForInitialConnect=false] Indicates the client can publish even before connecting. Will also change behaviour of the connect call
* @memberof NatsBufferedClient
*/
constructor(bufferSize?: number, reconnectTimeout?: number);
constructor(bufferSize?: number, reconnectTimeout?: number, waitForInitialConnection?: boolean);
/**

@@ -101,3 +110,3 @@ * Connect to the NATS server

*/
connect(clusterId: string, clientId: string, options?: nats.StanOptions): Promise<void>;
connect(clusterId: string, clientId: string, options?: nats.StanOptions): Promise<boolean>;
/**

@@ -104,0 +113,0 @@ * Closes the current NATS server connection

2

package.json
{
"name": "node-nats-streaming-buffered-client",
"version": "1.1.2",
"version": "1.2.0",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

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