Skip to content
/ zthrottle Public

tool to throttle a pipeline, so an expensive consumer gets a line less often

License

Notifications You must be signed in to change notification settings

anko/zthrottle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

zthrottle

Throttles a pipeline, only letting a line through at most every $1 seconds. After each cooldown interval, only the most recent line is printed.

If you've used lodash.js' _.throttle, this is that, but for the *NIX command line.

Example

Here's an illustration of what happens when you run—

firehose | zthrottle 1 | expensive

example of what happens

Arrows represent data being written.

Here's a GIF of that:

the same example as a GIF

Why

This is handy for when you have a crazy high rate firehose of data on an input stream, and a fairly expensive sink that processes them, and you don't want the sink to get lines too often, but you do want it to get the newest one whenever it does. So stick zthrottle in between:

firehose | zthrottle 1 | expensive
# -> `expensive` gets the most recent `firehose` line, but at 1 Hz

Install

Just put zthrottle in your $PATH.

You need zsh.

License

Unlicense. Public domain. Use freely.

About

tool to throttle a pipeline, so an expensive consumer gets a line less often

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages