class GV::Bedrock::Config

Etcd Client Service

Constants

CONFIG_DIR

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/gv/bedrock/config.rb, line 17
def initialize
  super
  
  # set tuple space as api
  @api = self.class.space
  
  # set default config values
  # by reading files in CONFIG_DIR
  # likely created on server setup
  Dir.glob("#{CONFIG_DIR}/*").each do |config_file|
    key = File.basename(config_file)
    value = (File.read(config_file).chomp rescue nil)          
    set key,value
  end

end

Public Instance Methods

clear() click to toggle source
# File lib/gv/bedrock/config.rb, line 47
def clear
 rem(nil) while get(nil)
end
get(key) click to toggle source

non blocking tuple reading

# File lib/gv/bedrock/config.rb, line 35
def get key
  @api.read([:config,key,nil],0)[2] rescue nil
end
rem(key) click to toggle source
# File lib/gv/bedrock/config.rb, line 43
def rem key
  @api.take([:config,key,nil],0) rescue nil
end
set(key, value) click to toggle source
# File lib/gv/bedrock/config.rb, line 39
def set key, value
  @api.write([:config,key,value])
end