Skip to content

Commit

Permalink
Unstable sending of chunked messages, closes #80; added node.js 19 to…
Browse files Browse the repository at this point in the history
… tests; readme minor changes
  • Loading branch information
kkamkou committed Nov 27, 2022
1 parent 029909d commit 8105001
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: ['lts/*', '0.12', '4', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18']
node-version: ['lts/*', '0.12', '4', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19']
# version 5 is glitching

steps:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ node-gelf - Graylog2 client library for Node.js. Pro - because of code-quality (
}
```

`npm install gelf-pro` (**ALL** node.js versions are supported [0.x to 18.x] :)
`npm install gelf-pro` (**ALL** node.js versions are supported [0.x to 19.x] :)

Library depends on: `lodash#~4.17`

Expand All @@ -24,8 +24,8 @@ var log = require('gelf-pro');

### Adapters

To provide predictable behaviour, all adapters do **NOT** re-use the socket connection.
There are multiple ([1](https://github.com/kkamkou/node-gelf-pro/pull/68), [2](https://github.com/fdelayen/node-gelf-pro/commit/b52b4b6b1ff26772314b8673dd6fd724c0937caa)) variants available which you can borrow from (and create a new adapter).
> :warning: To provide predictable behaviour, all existing adapters do **NOT** re-use the socket connection.
There are multiple ([1](https://github.com/kkamkou/node-gelf-pro/pull/68), [2](https://github.com/fdelayen/node-gelf-pro/commit/b52b4b6b1ff26772314b8673dd6fd724c0937caa)) variants available which you can borrow from (and create a new adapter).
[See related section](#third-party-adapters).

- UDP (with deflation and chunking)
Expand All @@ -36,8 +36,9 @@ There are multiple ([1](https://github.com/kkamkou/node-gelf-pro/pull/68), [2](h
- Input: `GELF TCP` (with `Null frame delimiter` and `Enable TLS`)


> *(hint)* withing more or less stable network (which is most likely) I would recommend using the "udp" adapter.
I would also recommend it for an average to high-loaded projects. For sensitive information "tcp-tls" adapter is recommended.
> Withing more or less stable network (which is most likely) I would recommend using the "udp" adapter.
I would also recommend it for an average to high-loaded project.
For sensitive information `tcp-tls` adapter is recommended.

### Configuration
```javascript
Expand Down
19 changes: 9 additions & 10 deletions lib/adapter/udp.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ adapter.send = function (message, callback) {
);
}

var packetId = Array.prototype.slice.call(crypto.randomBytes(8));
var packetId = Array.prototype.slice.call(crypto.randomBytes(8)),
chunksSent = 0;
for (var idx in chunks) {
if (isInterrupted) {
break;
Expand All @@ -110,16 +111,14 @@ adapter.send = function (message, callback) {
.from(self.specification.magicBytes.concat(packetId, idx, chunksCount, chunk));
client.send(
packet, 0, packet.length, self.options.port, self.options.host,
function (chunkIdx) {
return function (err, bytesSent) {
if (err) { return cbResults(err, 0); }
bytesSentTotal += bytesSent;
/* istanbul ignore else */
if (chunkIdx >= chunksCount - 1) {
cbResults(err, bytesSentTotal);
}
function (err, bytesSent) {
if (err) { return cbResults(err, 0); }
bytesSentTotal += bytesSent;
/* istanbul ignore else */
if (++chunksSent >= chunksCount) {
cbResults(err, bytesSentTotal);
}
}(idx)
}
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gelf-pro",
"version": "1.3.9",
"version": "1.3.10",
"main": "./lib/gelf-pro.js",
"typings": "./typings/index.d.ts",
"author": "Kanstantsin Kamkou <[email protected]>",
Expand Down

0 comments on commit 8105001

Please sign in to comment.