class Ray::Client
Public Class Methods
new(port = 23517, host = 'localhost')
click to toggle source
# File lib/ray/client.rb, line 6 def initialize(port = 23517, host = 'localhost') @port = port @host = host end
Public Instance Methods
lock_exists(lockName)
click to toggle source
# File lib/ray/client.rb, line 24 def lock_exists(lockName) req = Net::HTTP::Get.new("/locks/#{lockName}", { 'Content-Type' => 'application/json' }) begin response = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(req) end rescue StandardError return false end result = JSON.parse(response.body) if (result['stop_execution']) raise new StopExecutionRequested end return result['active'] || false end
send(request)
click to toggle source
# File lib/ray/client.rb, line 11 def send(request) req = Net::HTTP::Post.new(uri, { 'Content-Type' => 'application/json' }) req.body = request.to_json begin Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(req) end rescue StandardError # Ignore any errors end end
uri()
click to toggle source
# File lib/ray/client.rb, line 44 def uri @uri ||= URI("#{@host}:#{@port}") end