Class: Pi::Browser::Taskbar::Rails::Broker::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pi/browser/taskbar/rails/broker.rb

Constant Summary collapse

CONNECT_ATTEMPTS =
100
CONNECT_DELAY =
0.02

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_root:, executable: "pi", task_timeout: 1_800, runtime_root: nil) ⇒ Client

Returns a new instance of Client.



784
785
786
787
788
789
790
791
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 784

def initialize(project_root:, executable: "pi", task_timeout: 1_800, runtime_root: nil)
  @identity = Identity.new(project_root, runtime_root: runtime_root)
  @executable = executable
  @task_timeout = task_timeout
  @runtime_root = runtime_root
  @mutex = Mutex.new
  @pid = Process.pid
end

Instance Attribute Details

#identityObject (readonly)

Returns the value of attribute identity.



793
794
795
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 793

def identity
  @identity
end

Instance Method Details

#cancel(task_id) ⇒ Object



803
804
805
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 803

def cancel(task_id)
  request("type" => "cancel", "task_id" => task_id)
end

#closeObject



811
812
813
814
815
816
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 811

def close
  reset_after_fork
  @mutex.synchronize { discard_socket }
rescue IOError, SystemCallError
  @socket = nil
end

#resetObject



807
808
809
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 807

def reset
  request("type" => "reset")
end

#snapshotObject



795
796
797
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 795

def snapshot
  request("type" => "state")
end

#submit(task) ⇒ Object



799
800
801
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 799

def submit(task)
  request("type" => "submit", "task" => task)
end