Class: Phronomy::Runtime::ShutdownResult Private

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/engine/runtime/shutdown_result.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Immutable result returned by #shutdown.

runtime_outcome records whether execution remained healthy. It is intentionally independent from cleanup_status: a Runtime may fail during execution but still release every owned resource successfully.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime_outcome:, cleanup_status:, event_loop_status:, task_registry_status:, error: nil) ⇒ ShutdownResult

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ShutdownResult.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 27

def initialize(
  runtime_outcome:,
  cleanup_status:,
  event_loop_status:,
  task_registry_status:,
  error: nil
)
  @runtime_outcome = runtime_outcome
  @cleanup_status = cleanup_status
  @event_loop_status = event_loop_status
  @task_registry_status = task_registry_status
  @error = error
  freeze
end

Instance Attribute Details

#cleanup_statusObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 12

def cleanup_status
  @cleanup_status
end

#errorObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 12

def error
  @error
end

#event_loop_statusObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 12

def event_loop_status
  @event_loop_status
end

#runtime_outcomeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 12

def runtime_outcome
  @runtime_outcome
end

#task_registry_statusObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 12

def task_registry_status
  @task_registry_status
end

Class Method Details

.not_startedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
24
25
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 18

def self.not_started
  new(
    runtime_outcome: :terminated,
    cleanup_status: :complete,
    event_loop_status: :not_started,
    task_registry_status: :empty
  )
end

Instance Method Details

#clean?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true only for a graceful, error-free shutdown. A cancellation may release every resource, but is not considered clean.

Returns:

  • (Boolean)


49
50
51
52
53
54
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 49

def clean?
  @runtime_outcome == :terminated &&
    @cleanup_status == :complete &&
    %i[not_started terminated].include?(@event_loop_status) &&
    @task_registry_status == :empty
end

#cleanup_complete?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true when every Runtime-owned resource is known to have stopped.

Returns:

  • (Boolean)


43
44
45
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 43

def cleanup_complete?
  @cleanup_status == :complete
end

#success?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runtime reset is safe when cleanup completed, even if execution failed.

Returns:

  • (Boolean)


57
58
59
# File 'lib/phronomy/engine/runtime/shutdown_result.rb', line 57

def success?
  cleanup_complete?
end