class Imperium::Agent

A client for the Agent API.

Public Instance Methods

deregister_service(service_or_id) click to toggle source

Deregister a service with the agent.

@see www.consul.io/api/agent/service.html#deregister-service Consul's Documentation

@param service_or_id [Service, String] The object or id representing the

service to be removed from the services registry.
# File lib/imperium/agent.rb, line 14
def deregister_service(service_or_id)
  id = (service_or_id.is_a?(Service) ? service_or_id.id : service_or_id)
  Response.new(@http_client.put(prefix_path("service/deregister/#{id}"), ''))
end
list_checks() click to toggle source

Retreive a list of all checks registered to the local agent.

@see www.consul.io/api/agent/check.html#list-checks Consul's Documentation @return [AgentListChecksResponse]

# File lib/imperium/agent.rb, line 23
def list_checks
  response = @http_client.get(prefix_path('checks'))
  AgentListChecksResponse.new(response)
end
list_services() click to toggle source

Retreive a list of all services registered to the local agent.

@see www.consul.io/api/agent/service.html#list-services Consul's Documentation @return [AgentListServicesResponse]

# File lib/imperium/agent.rb, line 32
def list_services
  response = @http_client.get(prefix_path('services'))
  AgentListServicesResponse.new(response)
end
register_service(service) click to toggle source

Register a new service with the agent.

@see www.consul.io/api/agent/service.html#register-service Consul's Documentation

@param service [Serivce] A {Service} object containing the data to use

for registration
# File lib/imperium/agent.rb, line 43
def register_service(service)
  Response.new(@http_client.put(prefix_path('service/register'), service.registration_data))
end