Support interactive stdin/stdout streams#136
Merged
softprops merged 3 commits intosoftprops:masterfrom Dec 22, 2018
Merged
Conversation
This adds support for streaming stdin, stderr, and stdout independently
to a running container.
The underlying API is futures-based, meaning the code is implemented
asynchronously. A synchronous API is also exposed, which is implemented
by simply waiting on the asynchronous API futures.
This also modifies the existing Tty logic so that the storage type of
the data is a Vec<u8> rather than a String. This is also how the Rust
standard library persists data from the standard streams. In my
particular application, I'm using stdin/stdout as the communication
method between a container a host application. In it, a byte-based protocol is
used.
Streaming works by performing a TCP upgrade; upgrading a higher-level
HTTP connection to a lower-level TCP byte stream upon agreement with the
server. Docker will automatically upgrade HTTP container log requests to
TCP byte streams of a custom std{in,out,err} multiplexing protocol if
the client requests it with the 'Connection: Upgrade' header.
abusch
reviewed
Dec 11, 2018
|
|
||
| self.send_request(req).and_then(|res| { | ||
| if res.status() != StatusCode::SWITCHING_PROTOCOLS { | ||
| panic!("Our server didn't upgrade: {}", res.status()); |
Contributor
There was a problem hiding this comment.
It might be better to return a failed Future here, instead of panicking?
Also updates the examples to use them.
Contributor
Author
|
I've also added Tests pass on my machine, I can compile all examples, and all tests pass. One of the existing PRs to fix the existing |
Owner
|
apologize for the slow feedback cycle. I've been on vacation. there are some changes I think that need to happen in my travis build. I think pr check errors are unrelated to your changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for streaming stdin, stderr, and stdout independently
to a running container.
The underlying API is futures-based, meaning the code is implemented
asynchronously. A synchronous API is also exposed, which is implemented
by simply waiting on the asynchronous API futures.
This also modifies the existing Tty logic so that the storage type of
the data is a Vec rather than a String. This is also how the Rust
standard library persists data from the standard streams. In my
particular application, I'm using stdin/stdout as the communication
method between a container a host application. In it, a byte-based protocol is
used.
Streaming works by performing a TCP upgrade; upgrading a higher-level
HTTP connection to a lower-level TCP byte stream upon agreement with the
server. Docker will automatically upgrade HTTP container log requests to
TCP byte streams of a custom std{in,out,err} multiplexing protocol if
the client requests it with the 'Connection: Upgrade' header.
How did you verify your change:
I've got a project that implements a nontrivial byte-based protocol to send command/reply frames from the host app to the container over stdout/stdin. I can successfully parse, send, and process frames in both directions asynchronously with this patch.
What (if anything) would need to be called out in the CHANGELOG for the next release:
Container::logsfunction now returns atty::Chunktype containing raw bytes, rather than aTtyLineobject containing a UTF-8 string.