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

riemann

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

riemann - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

7

package.json
{
"name": "riemann",
"version": "1.1.0",
"version": "1.1.1",
"description": "node.js client for Riemann, supports hybrid UDP/TCP connections.",

@@ -14,3 +14,3 @@ "author": {

"engines": {
"node": "> 0.6.0"
"node": ">= 0.12"
},

@@ -22,3 +22,4 @@ "repository": {

"dependencies": {
"node-protobuf": "^1.4.3"
"node-protobuf": "^1.4.3",
"event-to-promise": "^0.8.0"
},

@@ -25,0 +26,0 @@ "devDependencies": {

@@ -53,2 +53,13 @@ # [Riemann](http://aphyr.github.com/riemann/) Node.js Client

Promise-based workflow is supported, too. Just pass 'returnPromise' flag set to _true_.
All the Client's methods will return promises in that case.
```js
var client = await require('riemann').createClient({
host: 'some.riemann.server',
port: 5555,
returnPromise: true
});
```
Just like [Riemann ruby client](https://github.com/aphyr/riemann-ruby-client), the client sends small events over UDP, by default. TCP is used for queries, and large events. There is no acknowledgement of UDP packets, but they are roughly an order of magnitude faster than TCP. We assume both TCP and UDP are listening to the same port.

@@ -78,2 +89,10 @@

}), client.tcp);
// ... or via promises
var data = await client.send(client.Event({
service: 'buffet_plates',
metric: 252.2,
tags: ['nonblocking']
}), client.tcp);
```

@@ -100,5 +119,8 @@

client.disconnect();
// ... or just
await client.disconnect();
```
## Contributing

@@ -110,3 +132,3 @@

- install Riemann using the [quickstart instructions](http://riemann.io/quickstart.html). A running Riemann server is required to run the tests.
- please add tests. I'm using [Mocha](http://visionmedia.github.com/mocha/) as a test runner, you can run the tests using `npm test`
- please add tests. I'm using [Mocha](https://mochajs.org/) as a test runner, you can run the tests using `npm test`
- please check your syntax with the included jshint configuration using `npm run-script lint`. It shouldn't report any errors.
var Client = require('./riemann/client').Client;
const e2p = require('event-to-promise');
// convenience method, how convenient.
exports.createClient = function(options, onConnect) {
return new Client(options, onConnect);
};
if (options.returnPromise) {
try {
const client = new Client(options);
return e2p(client, 'connect').then(() => client);
}
catch(err) {
return Promise.reject(err);
}
}
else {
return new Client(options, onConnect);
}
};

@@ -5,2 +5,3 @@ var assert = require('assert');

var hostname = require('os').hostname();
const e2p = require('event-to-promise');

@@ -18,2 +19,18 @@ /* riemann uses Google Protocol Buffers

/* allows to disconnect all those already
unnecessary 'data', 'sent' and 'error' handlers. */
function _e2p(emitter, event, options) {
let p = e2p(emitter, event, options);
return p.then(() => {
p.cancel();
return p;
})
.catch(err => {
p.cancel();
throw err;
});
}
var MAX_UDP_BUFFER_SIZE = 16384;

@@ -25,2 +42,3 @@ function _sendMessage(contents, transport) {

var message = Serializer.serializeMessage(contents);
let t;

@@ -30,3 +48,3 @@ // if an explict transport is specified via code,

if (transport) {
transport.send(message);
t = transport;

@@ -36,3 +54,3 @@ // if we're sending a message that is larger than the max buffer

} else if (message.length >= MAX_UDP_BUFFER_SIZE) {
self.tcp.send(message);
t = self.tcp;

@@ -42,4 +60,13 @@ // utilize whatever transport this message is applied to,

} else {
this.send(message);
t = this;
}
try {
if (self.returnPromise) {
return _e2p(self, t.promiseResolutionEvent);
}
}
finally {
t.send(message);
}
};

@@ -78,2 +105,5 @@ }

this.udp = new Socket.udpSocket(options);
this.tcp.promiseResolutionEvent = 'data';
this.udp.promiseResolutionEvent = 'sent';
this.returnPromise = options.returnPromise;

@@ -147,3 +177,4 @@ // monitor both close events, and proxy

}
payload.apply(transport);
return payload.apply(transport);
};

@@ -154,5 +185,14 @@

Client.prototype.disconnect = function(onDisconnect) {
if (onDisconnect) { this.once('disconnect', onDisconnect); }
if (this.tcp) { this.tcp.socket.end(); }
if (this.udp) { this.udp.socket.close(); }
try {
if (this.returnPromise) {
return _e2p(this, 'disconnect');
}
}
finally {
if (this.tcp) { this.tcp.socket.end(); }
if (this.udp) { this.udp.socket.close(); }
if (onDisconnect) {
this.once('disconnect', onDisconnect);
}
}
};
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