Skip to end of metadata
Go to start of metadata

To recap: io-cat is a utility extending cat functionality towards merging live streams. io-cat semantics is the same as cat on files, but it can merge streams, too, e.g. merge three streams:

> cat some-file.csv | io-cat - tcp:localhost:12345 local:some/socket > merged.csv

It supports a couple of simple merge policies: first come first serve by default, or round robin: e.g. try:

> yes STDIN | io-cat -  <( yes ANOTHER-STREAM ) <( yes THIRD-STREAM ) --round-robin 1 | head
STDIN
ANOTHER-STREAM
THIRD-STREAM
STDIN
ANOTHER-STREAM
THIRD-STREAM
STDIN
ANOTHER-STREAM
THIRD-STREAM
STDIN

Now, io-cat also can wait for publishing servers to start, using io-cat --connect-attempts option, e.g:

> io-cat tcp:localhost:8888 --connect-attempts unlimited -v
io-cat: stream 0 (tcp:localhost:8888): connecting, attempt 1 of unlimited...
io-cat: stream 0 (tcp:localhost:8888): failed to connect
io-cat: stream 0 (tcp:localhost:8888): connecting, attempt 2 of unlimited...
io-cat: stream 0 (tcp:localhost:8888): failed to connect
...

See io-cat --help for more configuration options.

Last but not least, broadly, the right approach to persistent clients would be using a publish/subscribe middleware, of your liking. ZeroMQ is a light-weight choice (and comma zero-cat supports a core subset of it). However, if you just want to quickly cobble together simple merging of multiple streams, potentially from heterogeneous sources, io-cat is there for you.

 

  • No labels