bundling-stream
v0.1.1
Published
bundle the writing data for decreasing the IOPS. such as writing logs to disk.
Downloads
2
Readme
bundling-stream
Bundle the writing data for decreasing the IOPS. such as writing logs to disk.
This feature is consider from the Nginx buffering access log config:
access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];
Install
npm install bundling-stream
API
BunlingStream(options)
options
- buffer Default:4096. size of bundling data.
- timing Default:false. actived flush timing in seconds.
The bundled data will be flush:
- if the next log line does not fit into the buffer;
- if the buffered data is older than specified by the timing parameter in seconds.
- finish writing: end() has been called.
const fs = require("fs");
var bws = require('bundling-stream')({"buffer":4096, "timing":10});
var fsteam = fs.createWriteSteam("access.log", {flags:"a+"});
bws.pipe(fsteam); // pipe to a fileWiteSteam.
for(var i=0; i<100000; i++){
bws.write("some log message.\n");
}