Module: Consul::Client::Agent::Service

Defined in:
lib/consul/client/agent.rb

Overview

Container Module for simpler way to create a service.

Class Method Summary collapse

Class Method Details

.for_name(name, check = nil) ⇒ Object

Public: Creates a service using a specific name

name - Name of the service to create check - The Consul::Model::HealthCheck instance to associate with this Session

Returns: Consul::Model::Service instance



266
267
268
269
270
271
272
273
274
275
276
# File 'lib/consul/client/agent.rb', line 266

def self.for_name(name, check = nil)
  raise ArgumentError.new "Illegal name: \"#{name}\" for service." if name.nil?
  unless check.nil? or check.is_a?(Consul::Model::HealthCheck)
    raise TypeError.new "Illegal Check type: #{check}.  Expecting Consul::Model::HealthCheck"
  end
  if check.nil?
    Consul::Model::Service.new(name: name)
  else # There is a health check to register
    Consul::Model::Service.new(name: name, check: check)
  end
end

.http_health_check(http, interval) ⇒ Object

Returns: Consul::Model::HealthCheck instance that represents a http health check.



284
285
286
# File 'lib/consul/client/agent.rb', line 284

def self.http_health_check(http, interval)
  Consul::Model::HealthCheck.new(http: http, interval: interval)
end

.script_health_check(script, interval) ⇒ Object

Returns: Consul::Model::HealthCheck instance that represents a script



279
280
281
# File 'lib/consul/client/agent.rb', line 279

def self.script_health_check(script, interval)
  Consul::Model::HealthCheck.new(script: script, interval: interval)
end

.ttl_health_check(ttl) ⇒ Object



288
289
290
# File 'lib/consul/client/agent.rb', line 288

def self.ttl_health_check(ttl)
  Consul::Model::HealthCheck.new(ttl: ttl)
end