Skip to content

Commit

Permalink
Merge branch 'brightcove:master' into fix_170
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarfd authored Oct 7, 2021
2 parents 774dc4a + 8fcb044 commit 274d7b0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
14 changes: 12 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
CHANGELOG
=========

## 8.5.2 (2021-9-26)
* @amc6 TypeScript: add missing decrement overload type

## 8.5.1 (2021-9-2)
* @tim-crisp TypeScript: add stream to protocol string union type
* @bdeitte Bump path-parse (used just in dev builds) from 1.0.6 to 1.0.7

## 8.5.0 (2021-7-16)
* @maxday Add a closingFlushInterval option which allows stopping quicker

## 8.4.0 (2021-7-3)
@roim Use errorHandler when possible on UDS socket replace error
* @roim Use errorHandler when possible on UDS socket replace error

## 8.3.2 (2021-5-29)
@cmaddalozzo Close unix domain socket after unsuccessful attempts to connect
* @cmaddalozzo Close unix domain socket after unsuccessful attempts to connect

## 8.3.1 (2021-4-1)
* @dvd-z Fix date_happened to allow usage of numbers
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Parameters (specified as one object passed into hot-shots):
* `tcpGracefulRestartRateLimit`: Used only when the protocol is `tcp`. Time (ms) between re-creating the socket. Defaults to `1000`.
* `udsGracefulErrorHandling`: Used only when the protocol is `uds`. Boolean indicating whether to handle socket errors gracefully. Defaults to true.
* `udsGracefulRestartRateLimit`: Used only when the protocol is `uds`. Time (ms) between re-creating the socket. Defaults to `1000`.
* `closingFlushInterval`: Before closing, StatsD will check for inflight messages. Time (ms) between each check. Defaults to `50`.

### StatsD methods
All StatsD methods other than `event`, `close`, and `check` have the same API:
Expand Down
6 changes: 4 additions & 2 deletions lib/statsd.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const Client = function (host, port, prefix, suffix, globalize, cacheDns, mock,
this.udsGracefulErrorHandling = 'udsGracefulErrorHandling' in options ? options.udsGracefulErrorHandling : true;
this.udsGracefulRestartRateLimit = options.udsGracefulRestartRateLimit || UDS_DEFAULT_GRACEFUL_RESTART_LIMIT; // only recreate once per second
this.isChild = options.isChild;
this.closingFlushInterval = options.closingFlushInterval || 50;

// If we're mocking the client, create a buffer to record the outgoing calls.
if (this.mock) {
Expand Down Expand Up @@ -417,7 +418,7 @@ Client.prototype.close = function (callback) {
clearInterval(waitForMessages);
this._close(callback);
}
}, 50);
}, this.closingFlushInterval);
});
};

Expand Down Expand Up @@ -492,7 +493,8 @@ const ChildClient = function (parent, options) {
maxBufferSize : parent.maxBufferSize,
bufferFlushInterval: parent.bufferFlushInterval,
telegraf : parent.telegraf,
protocol : parent.protocol
protocol : parent.protocol,
closingFlushInterval : parent.closingFlushInterval
});
};
util.inherits(ChildClient, Client);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hot-shots",
"description": "Node.js client for StatsD, DogStatsD, and Telegraf",
"version": "8.4.0",
"version": "8.5.2",
"author": "Steve Ivy",
"types": "./types.d.ts",
"contributors": [
Expand Down
12 changes: 12 additions & 0 deletions test/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ describe('#init', () => {
skipClose = true;
});

it('should set the closingFlushInterval option with the provided value', () => {
statsd = createHotShotsClient({
closingFlushInterval: 10
}, clientType);
assert.strictEqual(statsd.closingFlushInterval, 10);
});

it('should set the closingFlushInterval option with the default value', () => {
statsd = createHotShotsClient({}, clientType);
assert.strictEqual(statsd.closingFlushInterval, 50);
});

it('should create a socket variable that is an instance of net.Socket if set to TCP', done => {
server = createServer('tcp', opts => {
statsd = createHotShotsClient(opts, clientType);
Expand Down
4 changes: 3 additions & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare module "hot-shots" {
path?: string;
port?: number;
prefix?: string;
protocol?: 'tcp' | 'udp' | 'uds';
protocol?: 'tcp' | 'udp' | 'uds' | 'stream';
sampleRate?: number;
socket?: dgram.Socket;
suffix?: string;
Expand All @@ -29,6 +29,7 @@ declare module "hot-shots" {
tcpGracefulRestartRateLimit?: number;
udsGracefulErrorHandling?: boolean;
udsGracefulRestartRateLimit?: number;
closingFlushInterval?: number;
}

export interface ChildClientOptions {
Expand Down Expand Up @@ -82,6 +83,7 @@ declare module "hot-shots" {
increment(stat: string | string[], value: number, sampleRate?: number, callback?: StatsCb): void;

decrement(stat: string): void;
decrement(stat: string, tags?: Tags): void;
decrement(stat: string | string[], value: number, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
decrement(stat: string | string[], value: number, tags?: Tags, callback?: StatsCb): void;
decrement(stat: string | string[], value: number, callback?: StatsCb): void;
Expand Down

0 comments on commit 274d7b0

Please sign in to comment.