Class: Sanford::HostData

Inherits:
Object
  • Object
show all
Defined in:
lib/sanford/host_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_host, options = nil) ⇒ HostData

Returns a new instance of HostData.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sanford/host_data.rb', line 15

def initialize(service_host, options = nil)
  configuration = service_host.configuration.to_hash.merge(remove_nil_values(options || {}))

  @name               = configuration[:name]
  @ip, @port          = configuration[:ip], configuration[:port]
  @pid_dir            = configuration[:pid_dir]
  @logger, @verbose   = configuration[:logger], configuration[:verbose_logging]
  @error_proc         = configuration[:error_proc]

  @handlers = service_host.versioned_services.inject({}) do |hash, (version, services)|
    hash.merge({ version => self.constantize_services(services) })
  end

  raise Sanford::InvalidHostError.new(service_host) if !self.port
end

Instance Attribute Details

#error_procObject (readonly)

When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.



13
14
15
# File 'lib/sanford/host_data.rb', line 13

def error_proc
  @error_proc
end

#ipObject (readonly)

When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.



13
14
15
# File 'lib/sanford/host_data.rb', line 13

def ip
  @ip
end

#loggerObject (readonly)

When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.



13
14
15
# File 'lib/sanford/host_data.rb', line 13

def logger
  @logger
end

#nameObject (readonly)

When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.



13
14
15
# File 'lib/sanford/host_data.rb', line 13

def name
  @name
end

#pid_dirObject (readonly)

When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.



13
14
15
# File 'lib/sanford/host_data.rb', line 13

def pid_dir
  @pid_dir
end

#portObject (readonly)

When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.



13
14
15
# File 'lib/sanford/host_data.rb', line 13

def port
  @port
end

#verboseObject (readonly)

When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.



13
14
15
# File 'lib/sanford/host_data.rb', line 13

def verbose
  @verbose
end

Instance Method Details

#handler_class_for(version, service) ⇒ Object



31
32
33
34
# File 'lib/sanford/host_data.rb', line 31

def handler_class_for(version, service)
  version_group = @handlers[version] || {}
  version_group[service] || raise(Sanford::NotFoundError)
end