Comparing version 1.1.1 to 2.0.0
{ | ||
"name": "riemann", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "node.js client for Riemann, supports hybrid UDP/TCP connections.", | ||
@@ -21,3 +21,3 @@ "author": { | ||
"dependencies": { | ||
"node-protobuf": "^1.4.3", | ||
"protobufjs": "6.8.8", | ||
"event-to-promise": "^0.8.0" | ||
@@ -24,0 +24,0 @@ }, |
@@ -5,29 +5,2 @@ # [Riemann](http://aphyr.github.com/riemann/) Node.js Client | ||
## Prerequisites | ||
Riemann uses [Google Protocol Buffers](https://github.com/google/protobuf), | ||
so please make sure it's installed beforehand. | ||
### Ubuntu/Debian via apt | ||
```sh | ||
apt-get install libprotobuf-dev | ||
``` | ||
### RHEL/Centos via yum | ||
```sh | ||
yum install protobuf-devel | ||
``` | ||
### Mac OS via homebrew | ||
```sh | ||
brew install protobuf | ||
``` | ||
### Windows | ||
https://github.com/fuwaneko/node-protobuf#windows | ||
## Installation | ||
@@ -34,0 +7,0 @@ |
@@ -74,3 +74,3 @@ var assert = require('assert'); | ||
if (!payload.host) { payload.host = hostname; } | ||
if (!payload.time) { payload.time = new Date().getTime()/1000; } | ||
if (!payload.time) { payload.time = Math.round(new Date().getTime()/1000); } | ||
if (typeof payload.metric !== "undefined" && payload.metric !== null) { | ||
@@ -77,0 +77,0 @@ payload.metric_f = payload.metric; |
@@ -0,1 +1,4 @@ | ||
var protobuf = require('protobufjs'); | ||
var path = require('path'); | ||
/* initialize our protobuf schema, | ||
@@ -5,13 +8,47 @@ and cache it in memory. */ | ||
if (!riemannSchema) { | ||
var Schema = require('node-protobuf'); | ||
var readFile = require('fs').readFileSync; | ||
riemannSchema = new Schema(readFile(__dirname+'/proto/proto.desc')); | ||
schemaLoad(); | ||
} | ||
function schemaLoad() { | ||
return new Promise((resolve, reject) => { | ||
if (riemannSchema) { | ||
resolve(); | ||
} | ||
protobuf.load(path.join(__dirname, '/proto/proto.proto'), (err, root) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
// Pull the message type out. | ||
riemannSchema = root; | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
exports.schemaLoad = schemaLoad; | ||
function _serialize(type, value) { | ||
return riemannSchema.serialize(value, type); | ||
var messageType = riemannSchema.lookupType(type); | ||
// https://www.npmjs.com/package/protobufjs#valid-message | ||
var errorString = messageType.verify(value); | ||
var message; | ||
// Using create is faster, so only fall back to fromObject in worst case. | ||
if (errorString) { | ||
message = messageType.fromObject(value); | ||
} else { | ||
message = messageType.create(value); | ||
} | ||
return messageType.encode(message).finish(); | ||
} | ||
function _deserialize(type, value) { | ||
return riemannSchema.parse(value, type); | ||
var messageType = riemannSchema.lookupType(type); | ||
var buffer = Buffer.from(value, 'binary'); | ||
return messageType.decode(buffer); | ||
} | ||
@@ -18,0 +55,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
17623
325
0
104
+ Addedprotobufjs@6.8.8
+ Added@protobufjs/aspromise@1.1.2(transitive)
+ Added@protobufjs/base64@1.1.2(transitive)
+ Added@protobufjs/codegen@2.0.4(transitive)
+ Added@protobufjs/eventemitter@1.1.0(transitive)
+ Added@protobufjs/fetch@1.1.0(transitive)
+ Added@protobufjs/float@1.0.2(transitive)
+ Added@protobufjs/inquire@1.1.0(transitive)
+ Added@protobufjs/path@1.1.2(transitive)
+ Added@protobufjs/pool@1.1.0(transitive)
+ Added@protobufjs/utf8@1.1.0(transitive)
+ Added@types/long@4.0.2(transitive)
+ Added@types/node@10.17.60(transitive)
+ Addedlong@4.0.0(transitive)
+ Addedprotobufjs@6.8.8(transitive)
- Removednode-protobuf@^1.4.3
- Removedbindings@1.5.0(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removednan@2.22.0(transitive)
- Removednode-protobuf@1.4.3(transitive)