Fix StackSender.Send to always honor the `W` and `R` modes, by:
1) returning a valid Sender and Receiver when the respective flags are set, and
2) returning a value which doesn't need to be Closed, when they are not.
This also moves `NopSender` and `NopReceiver` out of `utils`, to prevent
a circular dependency.
Signed-off-by: Solomon Hykes <solomon@docker.com>
* `utils.Buffer`: a Sender which stores messages in a slice
* `utils.Copy`: beam equivalent of `io.Copy`
* `utlis.NopSender`: a Sender which silently discards messages
* `utlis.NopReceiver`: a Receiver which always returns EOF
Copy can now handle arbitrary nesting of streams, without knowing the
underlying type of either the source or destination.
It does this by attempting `SendTo` and `ReceiveFrom`, then if that is
not supported, falling back to nested copies in separate goroutines.
Signed-off-by: Solomon Hykes <solomon@docker.com>
* Copy is the beam equivalent of `io.Copy`
* `ReceiveFrom` is the beam equivalent of `io.ReadFrom`
* `SendTo` is the beam equivalent of `io.WriteTo`
Signed-off-by: Solomon Hykes <solomon@docker.com>