Class: Microsandbox::PullSession
- Inherits:
-
Object
- Object
- Microsandbox::PullSession
- Includes:
- Enumerable
- Defined in:
- lib/microsandbox/sandbox.rb
Overview
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.
1088 1089 1090 |
# File 'lib/microsandbox/sandbox.rb', line 1088 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.
1096 1097 1098 1099 1100 1101 1102 1103 |
# File 'lib/microsandbox/sandbox.rb', line 1096 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.
1109 1110 1111 |
# File 'lib/microsandbox/sandbox.rb', line 1109 def sandbox @sandbox ||= Sandbox.new(@native.result) end |