Class: RubyReactor::Dsl::AsyncReactorBuilder
- Inherits:
-
Object
- Object
- RubyReactor::Dsl::AsyncReactorBuilder
- Includes:
- TemplateHelpers
- Defined in:
- lib/ruby_reactor/dsl/async_reactor_builder.rb
Overview
Builds the async_reactor dispatch step. Same argument mapping shape as
ComposeBuilder, but deliberately NOT a subclass of it: compose's
builder warns that a child's with_ordered_lock is ignored (true for an
inline child, which bypasses Reactor#run) whereas an async_reactor
child is dispatched through the full pre-enqueue sequence and DOES get its
ordering nonce.
Constant Summary
Constants included from StepSignals
Instance Attribute Summary collapse
-
#argument_mappings ⇒ Object
Returns the value of attribute argument_mappings.
-
#child_reactor_class ⇒ Object
Returns the value of attribute child_reactor_class.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #argument(child_input_name, source) ⇒ Object
- #build ⇒ Object
-
#initialize(name, child_reactor_class, reactor = nil) ⇒ AsyncReactorBuilder
constructor
A new instance of AsyncReactorBuilder.
- #retries(max_attempts: 3, backoff: :exponential, base_delay: 1) ⇒ Object
Methods included from TemplateHelpers
#Failure, #Halt, #Skipped, #Success, #element, #input, #result, #value
Methods included from StepSignals
#fail!, #halt!, #skip!, #success!
Constructor Details
#initialize(name, child_reactor_class, reactor = nil) ⇒ AsyncReactorBuilder
Returns a new instance of AsyncReactorBuilder.
16 17 18 19 20 21 22 |
# File 'lib/ruby_reactor/dsl/async_reactor_builder.rb', line 16 def initialize(name, child_reactor_class, reactor = nil) @name = name @child_reactor_class = child_reactor_class @reactor = reactor @argument_mappings = {} @retry_config = {} end |
Instance Attribute Details
#argument_mappings ⇒ Object
Returns the value of attribute argument_mappings.
14 15 16 |
# File 'lib/ruby_reactor/dsl/async_reactor_builder.rb', line 14 def argument_mappings @argument_mappings end |
#child_reactor_class ⇒ Object
Returns the value of attribute child_reactor_class.
14 15 16 |
# File 'lib/ruby_reactor/dsl/async_reactor_builder.rb', line 14 def child_reactor_class @child_reactor_class end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/ruby_reactor/dsl/async_reactor_builder.rb', line 14 def name @name end |
Instance Method Details
#argument(child_input_name, source) ⇒ Object
24 25 26 |
# File 'lib/ruby_reactor/dsl/async_reactor_builder.rb', line 24 def argument(child_input_name, source) @argument_mappings[child_input_name] = source end |
#build ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ruby_reactor/dsl/async_reactor_builder.rb', line 32 def build RubyReactor::Dsl::StepConfig.new( async_dispatch: :reactor, name: @name, impl: RubyReactor::Step::AsyncReactorStep, arguments: { async_reactor_class: { source: RubyReactor::Template::Value.new(@child_reactor_class) }, argument_mappings: { source: RubyReactor::Template::Value.new(@argument_mappings) } }, run_block: nil, # No compensate/undo: the child is deliberately outside the parent's # compensation graph. Compensation is opt-in, via a later step # that reads `result(:name)` and decides to fail. compensate_block: nil, undo_block: nil, conditions: [], guards: [], dependencies: dependencies_from_mappings, args_validator: nil, output_validator: nil, retry_config: @retry_config.empty? ? (@reactor&.retry_defaults || {}) : @retry_config ) end |
#retries(max_attempts: 3, backoff: :exponential, base_delay: 1) ⇒ Object
28 29 30 |
# File 'lib/ruby_reactor/dsl/async_reactor_builder.rb', line 28 def retries(max_attempts: 3, backoff: :exponential, base_delay: 1) @retry_config = { max_attempts: max_attempts, backoff: backoff, base_delay: base_delay } end |