Class: Docker::API::Stream::Demultiplexer
- Inherits:
-
Object
- Object
- Docker::API::Stream::Demultiplexer
- Defined in:
- lib/docker/api/stream.rb
Overview
Splits Docker's multiplexed stdout/stderr framing back into named streams.
Used whenever a container was created without a TTY. With a TTY the daemon sends unframed bytes instead, which is what Raw is for.
Instance Method Summary collapse
-
#<<(chunk) ⇒ self
Feed bytes in.
-
#initialize {|name, chunk| ... } ⇒ Demultiplexer
constructor
A new instance of Demultiplexer.
-
#pending? ⇒ Boolean
Whether bytes are being held back for a partial frame.
Constructor Details
#initialize {|name, chunk| ... } ⇒ Demultiplexer
Returns a new instance of Demultiplexer.
36 37 38 39 40 41 |
# File 'lib/docker/api/stream.rb', line 36 def initialize(&block) raise ArgumentError, "Demultiplexer needs a block to yield frames to" unless block @block = block @buffer = +"".b end |
Instance Method Details
#<<(chunk) ⇒ self
Feed bytes in. Complete frames are yielded; a partial frame is held until the rest of it arrives.
48 49 50 51 52 |
# File 'lib/docker/api/stream.rb', line 48 def <<(chunk) @buffer << chunk.to_s.b emit_frames self end |
#pending? ⇒ Boolean
Returns whether bytes are being held back for a partial frame.
55 56 57 |
# File 'lib/docker/api/stream.rb', line 55 def pending? !@buffer.empty? end |