Skip to content

FGRibreau/stream-valve

Repository files navigation

stream-valve Deps Version CI Twitter Follow available-for-advisory Get help on Codementor

Ensure that a stream disconnects if it goes over maxBytes perSeconds

Sponsored by

Stream-valve development was sponsored by Redsmin, a fully loaded administration service for Redis.

Setup

npm install stream-valve

Usage

var valve = require('stream-valve');

socket = net.connect(6379, '127.0.0.1');

socket.on('error', function(err){
    // if valve maximum is reached a ESOCKETOVERFLOW error
    // will be emitted and the socket will be destroyed.
});

// disconnect the socket if it receive more than 1MB per 2 seconds
valve(socket, 1024 * 1024, 2);

socket.on('data', function(){
    // ...
});

Donate

I maintain this project in my free time, if it helped you please support my work via paypal or bitcoins, thanks a lot!

About

🔐 Ensure that a stream disconnects if it goes over `maxBytes` `perSeconds`

Resources

License

Stars

Watchers

Forks

Packages

No packages published