Class: Kanal::Core::Helpers::ResponseExecutionBlock
- Inherits:
-
Object
- Object
- Kanal::Core::Helpers::ResponseExecutionBlock
- Includes:
- Logging::Logger, Output
- Defined in:
- lib/kanal/core/helpers/response_execution_block.rb
Overview
This class executes response block and constructs output It is also can execute response block and disable moving it forward to the queue
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#response_block ⇒ Object
readonly
Returns the value of attribute response_block.
Instance Method Summary collapse
-
#execute(core, input_output_pair_queue) ⇒ void
Execute response block and ship created output into the queue.
-
#initialize(response_block, input, default_error_node, error_node) ⇒ ResponseExecutionBlock
constructor
Creating response execution block with all needed parameters.
Methods included from Logging::Logger
Constructor Details
#initialize(response_block, input, default_error_node, error_node) ⇒ ResponseExecutionBlock
Creating response execution block with all needed parameters
29 30 31 32 33 34 |
# File 'lib/kanal/core/helpers/response_execution_block.rb', line 29 def initialize(response_block, input, default_error_node, error_node) @response_block = response_block @input = input @default_error_node = default_error_node @error_node = error_node end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
19 20 21 |
# File 'lib/kanal/core/helpers/response_execution_block.rb', line 19 def input @input end |
#response_block ⇒ Object (readonly)
Returns the value of attribute response_block.
19 20 21 |
# File 'lib/kanal/core/helpers/response_execution_block.rb', line 19 def response_block @response_block end |
Instance Method Details
#execute(core, input_output_pair_queue) ⇒ void
This method returns an undefined value.
Execute response block and ship created output into the queue
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/kanal/core/helpers/response_execution_block.rb', line 44 def execute(core, input_output_pair_queue) if response_block.async? # NOTE: Thread doesnt just die here - it's execution is continued in input_output_pair_queue.enqueue in router # then :item_queued hook is called inside and subsequently output_ready_block gets called in this thread # TODO: be aware that this can cause unexpected behaviour. Maybe think how to rework it. Thread.new do output = construct_output core unless output.canceled? input_output_pair_queue.enqueue InputOutputPair.new(@input, output) end end else output = construct_output core unless output.canceled? input_output_pair_queue.enqueue InputOutputPair.new(@input, output) end end end |