Commit Graph

15 Commits

Author SHA1 Message Date
Solomon Hykes 396253a4ee StackSender.Send never returns a nil value
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>
2014-06-01 23:30:33 +00:00
Solomon Hykes c6f0a70141 Move utilities and interfaces out of `inmem`
* `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
2014-05-19 13:45:33 -07:00
Solomon Hykes c2c078952c Move unix implementation to a sub-package, promote inmem interfaces to top-level
[Signed-off-by: Solomon Hykes <solomon@docker.com>]
[Signed-off-by: Paul Nasrat <pnasrat@gmail.com>]
2014-05-18 14:40:44 -07:00
Solomon Hykes b9c316df29 inmem: complete Copy implementation
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>
2014-05-16 18:48:13 -07:00
Solomon Hykes 1508c1d46f inmem: PipeSender and PipeReceiver return clean nil values
This is necessary because `(*PipeSender)nil` is not equal to
`(interface{})nil`.

Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:48:13 -07:00
Solomon Hykes 048bed0cd1 inmem: a message is simply 1 opcode + an array of binary strings.
Remove redundant `Data` field. Every argument can be arbitrary data.

Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:48:13 -07:00
Solomon Hykes 7d0ba6e26b inmem: Sender implements Close
Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:46:24 -07:00
Solomon Hykes 6616f08fe0 inmem: gofmt
Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:46:23 -07:00
Solomon Hykes f22b8f52f3 inmem: Receiver and Sender don't need to implement Close
Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:46:23 -07:00
Solomon Hykes 91133d63be inmem: Fix PipeSender to implement ReceiverFrom
Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:46:23 -07:00
Solomon Hykes 0feebd2320 inmem: Implement `Copy`, `ReceiveFrom` and `SendTo`
* 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>
2014-05-16 18:44:23 -07:00
Solomon Hykes 338a7d50a8 inmem: fix nested in/out channels in each message
Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:41:38 -07:00
Solomon Hykes a1ed1ec1fa inmem: switch to a Sender/Receiver/Pipe interface similar to io.Pipe
Signed-off-by: Solomon Hykes <solomon@docker.com>
2014-05-16 18:40:31 -07:00
Solomon Hykes c0364720db beam: no target field yet 2014-05-09 21:00:46 -07:00
Solomon Hykes 3725628467 Beam in-mem: an in-memory implementation of Beam 2014-05-09 21:00:46 -07:00