class EurekaRuby::Executor

Attributes

client[R]

Public Class Methods

new() click to toggle source
# File lib/eureka_ruby/executor.rb, line 9
def initialize
  api_base = EurekaRuby.configuration.eureka_url
  timeout = 30
  skip_verify_ssl = EurekaRuby.configuration.scheme == 'http'
  @client = HttpClient.new(api_base, timeout, skip_verify_ssl)
end

Public Instance Methods

run(action_type) click to toggle source
# File lib/eureka_ruby/executor.rb, line 16
def run(action_type)
  raise 'Unknow message type' unless [:send_heartbeat, :register, :deregister].include?(action_type)
  case action_type
  when :send_heartbeat
    send_heartbeat
  when :register
    register_application_instance
  when :deregister
    deregister_application_instance
  end
end

Private Instance Methods

deregister_application_instance() click to toggle source
# File lib/eureka_ruby/executor.rb, line 38
def deregister_application_instance
  client.delete EurekaRuby.configuration.instance_path
end
register_application_instance() click to toggle source
# File lib/eureka_ruby/executor.rb, line 34
def register_application_instance
  client.post EurekaRuby.configuration.application_path, EurekaRuby.configuration.register_payload
end
send_heartbeat() click to toggle source
# File lib/eureka_ruby/executor.rb, line 30
def send_heartbeat
  client.put EurekaRuby.configuration.instance_path
end