Class: DeadmanCheck::KeySet

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

Overview

KeySet Class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, key) ⇒ KeySet

Returns a new instance of KeySet.



10
11
12
13
14
# File 'lib/deadman_check_keyset.rb', line 10

def initialize(host, port, key)
  @host = host
  @port = port
  @key  = key
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/deadman_check_keyset.rb', line 8

def host
  @host
end

#keyObject

Returns the value of attribute key.



8
9
10
# File 'lib/deadman_check_keyset.rb', line 8

def key
  @key
end

#portObject

Returns the value of attribute port.



8
9
10
# File 'lib/deadman_check_keyset.rb', line 8

def port
  @port
end

Instance Method Details

#_configure_diplomat(host, port) ⇒ Object



16
17
18
19
20
# File 'lib/deadman_check_keyset.rb', line 16

def _configure_diplomat(host, port)
  Diplomat.configure do |config|
    config.url = "http://#{host}:#{port}"
  end
end

#_update_consul_key(host, port, key) ⇒ Object



22
23
24
25
26
27
# File 'lib/deadman_check_keyset.rb', line 22

def _update_consul_key(host, port, key)
  DeadmanCheck::DeadmanCheckGlobal.new.configure_diplomat(host, port)
  epoch_time_now = DeadmanCheck::DeadmanCheckGlobal.new.get_epoch_time
  Diplomat::Kv.put(key, "#{epoch_time_now}")
  puts "Consul key #{key} updated EPOCH to #{epoch_time_now}"
end

#run_consul_key_updateObject



29
30
31
# File 'lib/deadman_check_keyset.rb', line 29

def run_consul_key_update
  _update_consul_key(@host, @port, @key)
end