Class: Ikibana::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ikibana/config.rb

Overview

Configuration class for NATS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file = "config/nats.yaml") ⇒ Config

Returns a new instance of Config.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ikibana/config.rb', line 26

def initialize(config_file = "config/nats.yaml")
  @config = load_config(config_file)
  @connection_string = @config["connection"]["url"]
  @logger = Logger.new($stdout)
  connect
  create_streams
rescue NATS::IO::Timeout
  @logger.error("NATS server not responding")
rescue StandardError => e
  @logger.error("#{e.class}: Error connecting to NATS server: #{e.message}")
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



24
25
26
# File 'lib/ikibana/config.rb', line 24

def cache
  @cache
end

#configObject (readonly)

Returns the value of attribute config.



23
24
25
# File 'lib/ikibana/config.rb', line 23

def config
  @config
end

#connection_stringObject (readonly)

Returns the value of attribute connection_string.



23
24
25
# File 'lib/ikibana/config.rb', line 23

def connection_string
  @connection_string
end

#consumersObject

Returns the value of attribute consumers.



24
25
26
# File 'lib/ikibana/config.rb', line 24

def consumers
  @consumers
end

#jsObject (readonly)

Returns the value of attribute js.



23
24
25
# File 'lib/ikibana/config.rb', line 23

def js
  @js
end

#loggerObject

Returns the value of attribute logger.



24
25
26
# File 'lib/ikibana/config.rb', line 24

def logger
  @logger
end

#natsObject (readonly)

Returns the value of attribute nats.



23
24
25
# File 'lib/ikibana/config.rb', line 23

def nats
  @nats
end

Class Method Details

.configure(_config_file = "config/nats.yaml") {|instance| ... } ⇒ Object

Yields:

  • (instance)


38
39
40
# File 'lib/ikibana/config.rb', line 38

def self.configure(_config_file = "config/nats.yaml")
  yield instance if block_given?
end