class Lono::Sets::Status::Instance
The Completed
and Deleted
classes inherit from Base
. They implement `tail` and should not override `show`.
They guarantee at least one status line is shown. After which they start a thread that tails until a “terminal” status is detected. However, describe_stack_instance resp.stack_instance.status returns:
CURRENT, OUTDATED, INOPERABLE
There is no well-defined terminal status. For example, sometimes the terminal status is `CURRENT`, when the stack instance updates successfully:
CURRENT -> OUTDATED -> CURRENT (terminal)
But sometimes the terminal state is `OUTDATED`, when the stack instance fails to update:
CURRENT -> OUTDATED (terminal)
Essentially, the `describe_stack_instance` resp does not provide enough information to determine the completion of the `tail` logic.
Hence the Completed
and Deleted
classes cannot be used to control the end of the polling loop. Instead, the calling logic is responsible for and should control when to end the polling loop.
Example in Lono::Sets::Status::Instances:
with_instances do |instance| Thread.new { instance.tail(to) } end.map(&:join) wait_until_stack_set_operation_complete
The Instances logic waits on the operation results instead because its more accurate. We know from `describe_stack_set_operation` when the status is actually complete. The describe_stack_set_operation stack_set_operation.status is one of RUNNING, SUCCEEDED, FAILED, STOPPING, STOPPED.
In this case, there are threads within threads. The first thread at the Instances level starts polling status in parallel. The instance.tail delegates to the Completed
and Deleted
classes.
Finally, the Completed
and Deleted
classes are designed to block with the first poll request. So it can show at least one status line. Then it starts it's own thread to poll for more statuses. Those latter statuses are not guaranteed to be shown. This is the responsibility of the Instances class since it has the information required to determine when to finish the polling loop.
Refer to Lono::Sets::Status::Instance::Base
for more detailed docs.
Refer to Lono::Sets::Status::Instance::Base
for more detailed docs.
Public Class Methods
# File lib/lono/sets/status/instance.rb, line 3 def initialize(stack_instance) @stack_instance = stack_instance end
Public Instance Methods
# File lib/lono/sets/status/instance.rb, line 16 def show Show.new(@stack_instance).run end
# File lib/lono/sets/status/instance.rb, line 7 def tail(to="completed") case to when "completed" Completed.new(@stack_instance).tail when "deleted" Deleted.new(@stack_instance).tail end end