Class: Gotta::Run::DynamicRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/gotta/run.rb,
lib/gotta/run/dynamic_runner.rb

Overview

This class is responsible for all dynamic runners. It was designed to be used as a inheritable class. For example: ‘class RubyRunner < Gotta::Run::DynamicRunner; end`

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_queue: Gotta::Queue.new('input'), runtime_path: nil, &block) ⇒ DynamicRunner

The initializer takes an input queue, where it should go fetch payloads to send to runners. The default queue is ‘Gotta::Queue::Memory::Driver`. It also takes an optional argument `runtime_path` that is the path to the runtime script for the language you want to run. You can optionally pass a block in case you need to set extra configuration without having to override the initializer. It will raise `RuntimeScriptNotFound` if `runtime_path` doesn’t exist or is not a file.

Raises:

  • (RuntimeScriptNotFound)


46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gotta/run.rb', line 46

def initialize(input_queue: Gotta::Queue.new('input'),
               runtime_path: nil,
               &block)
  @input_queue = input_queue
  @runtime_path = runtime_path
  raise RuntimeScriptNotFound, path unless File.file?(runtime_path)

  @parent_socket, @child_socket = UNIXSocket.pair
  @child_output_r, @child_output_w = IO.pair
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#input_queueObject (readonly)

Returns the value of attribute input_queue.



33
34
35
# File 'lib/gotta/run.rb', line 33

def input_queue
  @input_queue
end

Instance Method Details

#startObject



58
59
60
61
62
# File 'lib/gotta/run.rb', line 58

def start
  start_runtime
  @child_stdout_thread = connect_to_child_stdout
  start_processing
end