Class: Aidp::Execute::DeterministicUnits::Definition
- Inherits:
-
Object
- Object
- Aidp::Execute::DeterministicUnits::Definition
- Defined in:
- lib/aidp/execute/deterministic_unit.rb
Overview
Represents a deterministic unit configured in aidp.yml. Definitions are immutable and provide helper accessors used by the scheduler.
Constant Summary collapse
- VALID_TYPES =
[:command, :wait].freeze
- NEXT_KEY_ALIASES =
{ if_pass: :success, if_success: :success, if_fail: :failure, if_failure: :failure, if_error: :failure, if_timeout: :timeout, if_wait: :waiting, if_new_item: :event, if_event: :event }.freeze
Instance Attribute Summary collapse
-
#backoff_multiplier ⇒ Object
readonly
Returns the value of attribute backoff_multiplier.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#max_backoff_seconds ⇒ Object
readonly
Returns the value of attribute max_backoff_seconds.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#min_interval_seconds ⇒ Object
readonly
Returns the value of attribute min_interval_seconds.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#next_map ⇒ Object
readonly
Returns the value of attribute next_map.
-
#output_file ⇒ Object
readonly
Returns the value of attribute output_file.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #command? ⇒ Boolean
-
#initialize(config) ⇒ Definition
constructor
A new instance of Definition.
- #next_for(result_status, default: nil) ⇒ Object
- #wait? ⇒ Boolean
Constructor Details
#initialize(config) ⇒ Definition
Returns a new instance of Definition.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 32 def initialize(config) @name = config.fetch(:name) @type = normalize_type(config[:type]) || default_type_for(config) validate_type! @command = config[:command] @output_file = config[:output_file] @next_map = normalize_next_config(config[:next] || {}) @min_interval_seconds = config.fetch(:min_interval_seconds, 60) @max_backoff_seconds = config.fetch(:max_backoff_seconds, 900) @backoff_multiplier = config.fetch(:backoff_multiplier, 2.0) @enabled = config.fetch(:enabled, true) @metadata = config.fetch(:metadata, {}).dup end |
Instance Attribute Details
#backoff_multiplier ⇒ Object (readonly)
Returns the value of attribute backoff_multiplier.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def backoff_multiplier @backoff_multiplier end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def command @command end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def enabled @enabled end |
#max_backoff_seconds ⇒ Object (readonly)
Returns the value of attribute max_backoff_seconds.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def max_backoff_seconds @max_backoff_seconds end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def @metadata end |
#min_interval_seconds ⇒ Object (readonly)
Returns the value of attribute min_interval_seconds.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def min_interval_seconds @min_interval_seconds end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def name @name end |
#next_map ⇒ Object (readonly)
Returns the value of attribute next_map.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def next_map @next_map end |
#output_file ⇒ Object (readonly)
Returns the value of attribute output_file.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def output_file @output_file end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
28 29 30 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 28 def type @type end |
Instance Method Details
#command? ⇒ Boolean
47 48 49 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 47 def command? type == :command end |
#next_for(result_status, default: nil) ⇒ Object
55 56 57 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 55 def next_for(result_status, default: nil) next_map[result_status.to_sym] || default || next_map[:else] end |
#wait? ⇒ Boolean
51 52 53 |
# File 'lib/aidp/execute/deterministic_unit.rb', line 51 def wait? type == :wait end |