tank 3plumb 2012-08-12

NAME

tank - buffer datagrams

SYNPOSIS

[tank maxnum=100 maxlen=1000 event=1 len_overrun_msg="str1" num_overrun_msg="str2"]

                   3
               (control)
                   |
                   V
               +-------+
0 (stdin) ---->| tank  |----> (stdout) 1
               +-------+
                 |   |
                 V   V
          (stderr)   (events)
                 2   4

DESCRIPTION

Tank reads its stdin relaying messages to a single stdout until it blocks. When stdout is blocked, tank keeps on reading and collects incoming datagrams in a buffer. Order and size of datagrams are remembered. When output is unblocked, tank tries to write out accumulated datagrams.

There is a limit on maximum number of datagrams stored and another limit on the total amount of datagram bytes buffered. These have sensible defaults and can be changed using maxnum and maxlen arguments, respectively. Length is specified in bytes and does not include administrative memory overhead for each datagram (can be in the 100 byte range, per datagram).

When a maximum is reached, tank quits discarding all pending datagrams and prints the configured error message to stderr if len_overrun_msg or num_overrun_msg is set (respectively). If event is true a predefined error message is also printed to the central event dispatcher.

eof handling

EOF received on stdin while buffer is not empty is also buffered and sent to stdout only when all pending datagrams are delivered. EOF on stdout is immediately relayed to stdin.

blocking/flow control

Block on stdout causes buffering up to the predefined limits.

buffering

Datagram buffering as configured.

EXAMPLE

# make sure proc1 is not blocked even if proc2 lags sometimes
# to make proc1->proc2 flow smooth
{proc1} | h=[hub] | [tank maxlen=1000000] | {proc2}
h:* | {proc3}

SEE ALSO

tank 3plumb 2012-08-12