Class: ScriptCore::Runner
Instance Attribute Summary collapse
-
#message_processor_factory ⇒ Object
readonly
Returns the value of attribute message_processor_factory.
-
#service_process ⇒ Object
readonly
Returns the value of attribute service_process.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(timeout:, service_process:, message_processor_factory:) ⇒ Runner
constructor
A new instance of Runner.
- #run(*data) ⇒ Object
Constructor Details
#initialize(timeout:, service_process:, message_processor_factory:) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 |
# File 'lib/script_core/runner.rb', line 9 def initialize(timeout:, service_process:, message_processor_factory:) @timeout = timeout @service_process = service_process @message_processor_factory = end |
Instance Attribute Details
#message_processor_factory ⇒ Object (readonly)
Returns the value of attribute message_processor_factory.
7 8 9 |
# File 'lib/script_core/runner.rb', line 7 def @message_processor_factory end |
#service_process ⇒ Object (readonly)
Returns the value of attribute service_process.
7 8 9 |
# File 'lib/script_core/runner.rb', line 7 def service_process @service_process end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/script_core/runner.rb', line 7 def timeout @timeout end |
Instance Method Details
#run(*data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/script_core/runner.rb', line 15 def run(*data) = .new begin code = service_process.open do |channel| Timeout.timeout(timeout) do data.each { |datum| channel.write(datum) } .process_all(channel) end end if code > 255 .signal_signaled(code - 255) elsif code != 0 .signal_abnormal_exit(code) end rescue Timeout::Error .signal_error( ScriptCore::EngineTimeQuotaError.new(quota: timeout) ) end .to_result end |