Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hot-shots

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hot-shots - npm Package Compare versions

Comparing version 6.7.0 to 6.8.0

4

CHANGES.md
CHANGELOG
=========
## 6.8.0 (2019-10-14)
* @runk Add new protocol, stream, and a stream parameter for
specifying it.
## 6.7.0 (2019-10-9)

@@ -5,0 +9,0 @@ * @runk Code refactoring to have abstract transports

3

lib/statsd.js

@@ -53,3 +53,4 @@ const util = require('util'),

port: this.port,
protocol: this.protocol
protocol: this.protocol,
stream: options.stream
});

@@ -56,0 +57,0 @@ this.mock = options.mock;

@@ -0,1 +1,2 @@

const assert = require('assert');
const dgram = require('dgram');

@@ -10,2 +11,10 @@ const net = require('net');

const addEol = (buf) => {
let msg = buf.toString();
if (msg.length > 0 && msg[msg.length - 1] !== '\n') {
msg += '\n';
}
return msg;
};
// interface Transport {

@@ -26,7 +35,3 @@ // emit(name: string, payload: any):void;

send: (buf, callback) => {
let msg = buf.toString();
if (msg.length > 0 && msg[msg.length - 1] !== '\n') {
msg += '\n';
}
socket.write(msg, 'ascii', callback);
socket.write(addEol(buf), 'ascii', callback);
},

@@ -71,3 +76,3 @@ close: () => socket.destroy()

// close is synchronous, and the socket will not emit a
// close event, so we can callback right away
// close event, hence emulating standard behaviour by doing this:
socket.emit('close');

@@ -78,2 +83,22 @@ }

const createStreamTransport = (args) => {
const stream = args.stream;
assert(stream, '`stream` option required');
return {
emit: stream.emit.bind(stream),
on: stream.on.bind(stream),
removeListener: stream.removeListener.bind(stream),
send: (buf, callback) => stream.write(addEol(buf), callback),
close: () => {
stream.destroy();
// Node v8 doesn't fire `close` event on stream destroy.
if (process.version.split('.').shift() === 'v8') {
stream.emit('close');
}
}
};
};
module.exports = (instance, args) => {

@@ -90,2 +115,4 @@ let transport = null;

transport = createUdpTransport(args);
} else if (protocol === PROTOCOL.STREAM) {
transport = createStreamTransport(args);
} else {

@@ -92,0 +119,0 @@ throw new Error(`Unsupported protocol '${protocol}'`);

{
"name": "hot-shots",
"description": "Node.js client for StatsD, DogStatsD, and Telegraf",
"version": "6.7.0",
"version": "6.8.0",
"author": "Steve Ivy",

@@ -34,3 +34,3 @@ "types": "./types.d.ts",

"test": "mocha --exit -R spec --timeout 5000 test/*.js",
"lint": "eslint lib/**.js test/**.js",
"lint": "eslint lib/**/*.js test/**/*.js",
"pretest": "npm run lint"

@@ -37,0 +37,0 @@ },

@@ -48,4 +48,5 @@ # hot-shots

* `useDefaultRoute`: Use the default interface on a Linux system. Useful when running in containers
* `protocol`: Use `tcp` option for TCP protocol, or `uds` for the Unix Domain Socket protocol. Defaults to UDP otherwise
* `protocol`: Use `tcp` option for TCP protocol, or `uds` for the Unix Domain Socket protocol or `stream` for the raw stream. Defaults to `udp` otherwise.
* `path`: Used only when the protocol is `uds`. Defaults to `/var/run/datadog/dsd.socket`.
* `stream`: Reference to a stream instance. Used only when the protocol is `stream`.
* `udsGracefulErrorHandling`: Used only when the protocol is `uds`. Boolean indicating whether to handle socket errors gracefully. Defaults to true.

@@ -52,0 +53,0 @@ * `udsGracefulRestartRateLimit`: Used only when the protocol is `uds`. Time (ms) between re-creating the socket. Defaults to `1000`.

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