Class: Microsandbox::PullSession
- Inherits:
-
Object
- Object
- Microsandbox::PullSession
- Includes:
- Enumerable
- Defined in:
- lib/microsandbox/sandbox.rb
Overview
Single-pass, forward-only, single-consumer. each drains a
one-shot native progress channel — not rewindable, iterate once from a
single thread. #sandbox works whether or not you iterated (it awaits the
create either way), so you can skip each entirely; but don't expect a
second each to replay the events.
A streaming image-pull + create session, from Sandbox.create_with_progress. Iterate it (it is Enumerable) to consume progress-event Hashes as the image pulls, then call #sandbox to get the booted Sandbox. Each event Hash has a "kind" key (e.g. "resolving", "resolved", "layer_download_progress", "layer_materialize_progress", "complete") plus kind-specific fields.
Instance Method Summary collapse
-
#each {|event| ... } ⇒ self, Enumerator
Yield each progress-event Hash until the pull finishes.
-
#initialize(native) ⇒ PullSession
constructor
A new instance of PullSession.
-
#sandbox ⇒ Sandbox
The booted sandbox.
Constructor Details
#initialize(native) ⇒ PullSession
Returns a new instance of PullSession.
1136 1137 1138 |
# File 'lib/microsandbox/sandbox.rb', line 1136 def initialize(native) @native = native end |
Instance Method Details
#each {|event| ... } ⇒ self, Enumerator
Yield each progress-event Hash until the pull finishes. Returns an Enumerator when called without a block.
1144 1145 1146 1147 1148 1149 1150 1151 |
# File 'lib/microsandbox/sandbox.rb', line 1144 def each return enum_for(:each) unless block_given? while (event = @native.recv) yield event end self end |
#sandbox ⇒ Sandbox
The booted sandbox. Joins the create task (draining any remaining pull progress first), so call it after iterating progress. The returned Sandbox is live — stop it when done. Memoized; callable once.
1157 1158 1159 |
# File 'lib/microsandbox/sandbox.rb', line 1157 def sandbox @sandbox ||= Sandbox.new(@native.result) end |