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.



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

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.



791
792
793
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 791

def identity
  @identity
end

Instance Method Details

#cancel(task_id) ⇒ Object



801
802
803
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 801

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

#closeObject



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

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

#resetObject



805
806
807
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 805

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

#snapshotObject



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

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

#submit(task) ⇒ Object



797
798
799
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 797

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