Class: Invoker::DNSCache

Inherits:
Object
  • Object
show all
Defined in:
lib/invoker/dns_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ DNSCache

Returns a new instance of DNSCache.



5
6
7
8
9
10
11
12
13
# File 'lib/invoker/dns_cache.rb', line 5

def initialize(config)
  self.dns_data = {}
  @dns_mutex = Mutex.new
  Invoker.config.processes.each do |process|
    if process.port
      dns_data[process.label] = { 'port' => process.port }
    end
  end
end

Instance Attribute Details

#dns_dataObject

Returns the value of attribute dns_data.



3
4
5
# File 'lib/invoker/dns_cache.rb', line 3

def dns_data
  @dns_data
end

Instance Method Details

#[](process_name) ⇒ Object



15
16
17
# File 'lib/invoker/dns_cache.rb', line 15

def [](process_name)
  @dns_mutex.synchronize { dns_data[process_name] }
end

#add(name, port, ip = nil) ⇒ Object



19
20
21
# File 'lib/invoker/dns_cache.rb', line 19

def add(name, port, ip = nil)
  @dns_mutex.synchronize { dns_data[name] = { 'port' => port, 'ip' => ip } }
end