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

fluentd-node

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluentd-node - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

35

build/src/client.d.ts

@@ -50,2 +50,28 @@ import EventTime from "./event_time";

};
export declare type DisconnectOptions = {
/**
* The amount of time to wait between flush attempts on disconnection (after making at least one attempt)
*
* Useful to wait if the fluent server is unavailable right when we're disconnecting
*
* Defaults to 0
*/
flushDelay: number;
/**
* The number of times to attempt a flush on disconnection
*
* Useful to empty the send queue before disconnecting
*
* Defaults to 1
*/
maxFlushAttempts: number;
/**
* The amount of time to wait before disconnecting the socket on disconnection
*
* Useful to wait for acknowledgements on final flush
*
* Defaults to 0
*/
socketDisconnectDelay: number;
};
/**

@@ -133,2 +159,10 @@ * The constructor options passed to the client

eventRetry?: Partial<EventRetryOptions>;
/**
* Options to control disconnection behavior
*
* How many times to try to flush before disconnecting, wait times, etc
*
* See subtype for defaults
*/
disconnect?: Partial<DisconnectOptions>;
};

@@ -157,2 +191,3 @@ /**

private willFlushNextTick;
private disconnectOptions;
/**

@@ -159,0 +194,0 @@ * Creates a new FluentClient

22

build/src/client.js

@@ -78,2 +78,8 @@ "use strict";

options.sendQueueNotFlushableLimitDelay || 0;
this.disconnectOptions = {
flushDelay: 0,
maxFlushAttempts: 1,
socketDisconnectDelay: 0,
...(options.disconnect || {}),
};
this.socket = this.createSocket(options.security, options.socket);

@@ -220,5 +226,19 @@ this.socket.on("writable", () => this.handleWritable());

try {
await this.flush();
let flushCount = 0;
while (flushCount < this.disconnectOptions.maxFlushAttempts) {
// Only delay after making one flush attempt
if (flushCount > 0 && this.disconnectOptions.flushDelay > 0) {
await new Promise(r => setTimeout(r, this.disconnectOptions.flushDelay));
}
// Exit if flush returns false - queue is empty
if (!(await this.flush())) {
break;
}
flushCount += 1;
}
}
finally {
if (this.disconnectOptions.socketDisconnectDelay > 0) {
await new Promise(r => setTimeout(r, this.disconnectOptions.socketDisconnectDelay));
}
try {

@@ -225,0 +245,0 @@ await this.socket.disconnect();

2

build/src/index.d.ts

@@ -7,4 +7,4 @@ export { FluentClient } from "./client";

export type { EventRetryOptions } from "./event_retrier";
export type { FluentClientOptions, Timestamp, AckOptions, EventModes, SendQueueLimit, } from "./client";
export type { FluentClientOptions, Timestamp, AckOptions, EventModes, SendQueueLimit, DisconnectOptions, } from "./client";
export type { FluentServerOptions, FluentServerSecurityOptions } from "./server";
export * as FluentError from "./error";
{
"name": "fluentd-node",
"version": "0.0.9",
"version": "0.0.10",
"description": "A fluent protocol implementation in node",

@@ -5,0 +5,0 @@ "main": "./build/src/index.js",

@@ -80,2 +80,29 @@ import {

export type DisconnectOptions = {
/**
* The amount of time to wait between flush attempts on disconnection (after making at least one attempt)
*
* Useful to wait if the fluent server is unavailable right when we're disconnecting
*
* Defaults to 0
*/
flushDelay: number;
/**
* The number of times to attempt a flush on disconnection
*
* Useful to empty the send queue before disconnecting
*
* Defaults to 1
*/
maxFlushAttempts: number;
/**
* The amount of time to wait before disconnecting the socket on disconnection
*
* Useful to wait for acknowledgements on final flush
*
* Defaults to 0
*/
socketDisconnectDelay: number;
};
/**

@@ -164,2 +191,10 @@ * The constructor options passed to the client

eventRetry?: Partial<EventRetryOptions>;
/**
* Options to control disconnection behavior
*
* How many times to try to flush before disconnecting, wait times, etc
*
* See subtype for defaults
*/
disconnect?: Partial<DisconnectOptions>;
};

@@ -192,2 +227,3 @@

private willFlushNextTick: Promise<boolean> | null = null;
private disconnectOptions: DisconnectOptions;

@@ -251,2 +287,9 @@ /**

this.disconnectOptions = {
flushDelay: 0,
maxFlushAttempts: 1,
socketDisconnectDelay: 0,
...(options.disconnect || {}),
};
this.socket = this.createSocket(options.security, options.socket);

@@ -456,4 +499,22 @@

try {
await this.flush();
let flushCount = 0;
while (flushCount < this.disconnectOptions.maxFlushAttempts) {
// Only delay after making one flush attempt
if (flushCount > 0 && this.disconnectOptions.flushDelay > 0) {
await new Promise(r =>
setTimeout(r, this.disconnectOptions.flushDelay)
);
}
// Exit if flush returns false - queue is empty
if (!(await this.flush())) {
break;
}
flushCount += 1;
}
} finally {
if (this.disconnectOptions.socketDisconnectDelay > 0) {
await new Promise(r =>
setTimeout(r, this.disconnectOptions.socketDisconnectDelay)
);
}
try {

@@ -460,0 +521,0 @@ await this.socket.disconnect();

@@ -14,2 +14,3 @@ export {FluentClient} from "./client";

SendQueueLimit,
DisconnectOptions,
} from "./client";

@@ -16,0 +17,0 @@

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