stream-ack
ACK data chunks send over a Node.js stream
This package allow to send and receive messages in a Node.js stream to confirm that some data fragments has arrived to their destination, storing them until the confirmation message is received. In case the transport stream gets closed with some data fragment being confirmed, it's notified to the application so they can be send using another transport stream.
How it works
Sender stream will store written data chunks in a Map object used as cache.
When received by the receiver stream, a confirmation message is send back.
Confirm stream will receive it and remove the corresponding one from the cache
of sended data chunks,
API
Sender
- writable:
Writablestream wrapped to send the data and ACK messages - inFlight:
Mapobject used to cache de data chunks pending for confirmation - options: options passed to the underlying
Transformstream- idField: field inside the incoming message that host the confirmation ID
receiver
- writable:
Writablestream where to write confirmation messages - options: options passed to the underlying
Transformstream- ackPrefix: prefix used to identify the ACK magic message
- idField: field inside the incoming message that host the confirmation ID
confirm
- readable:
Readablestream wrapped to receive incoming ACK messages - inFlight:
Mapobject used to cache de data chunks pending for confirmation - options: options passed to the underlying
Readablestream- ackPrefix: prefix used to identify the ACK magic message
duplex
- duplex:
Duplexstream wrapped to send and receive data and ACK messages - options: options passed to underlying
duplexifystream object- confirm: options passed to underlying
Confirmstream - sender: options passed to underlying
Senderstream
- confirm: options passed to underlying