Class: Ikibana::Config
- Inherits:
-
Object
- Object
- Ikibana::Config
- Includes:
- Singleton
- Defined in:
- lib/ikibana/config.rb
Overview
Configuration class for NATS
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#connection_string ⇒ Object
readonly
Returns the value of attribute connection_string.
-
#consumers ⇒ Object
Returns the value of attribute consumers.
-
#js ⇒ Object
readonly
Returns the value of attribute js.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#nats ⇒ Object
readonly
Returns the value of attribute nats.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config_file = "config/nats.yaml") ⇒ Config
constructor
A new instance of Config.
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
#cache ⇒ Object
Returns the value of attribute cache.
24 25 26 |
# File 'lib/ikibana/config.rb', line 24 def cache @cache end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
23 24 25 |
# File 'lib/ikibana/config.rb', line 23 def config @config end |
#connection_string ⇒ Object (readonly)
Returns the value of attribute connection_string.
23 24 25 |
# File 'lib/ikibana/config.rb', line 23 def connection_string @connection_string end |
#consumers ⇒ Object
Returns the value of attribute consumers.
24 25 26 |
# File 'lib/ikibana/config.rb', line 24 def consumers @consumers end |
#js ⇒ Object (readonly)
Returns the value of attribute js.
23 24 25 |
# File 'lib/ikibana/config.rb', line 23 def js @js end |
#logger ⇒ Object
Returns the value of attribute logger.
24 25 26 |
# File 'lib/ikibana/config.rb', line 24 def logger @logger end |
#nats ⇒ Object (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
38 39 40 |
# File 'lib/ikibana/config.rb', line 38 def self.configure(_config_file = "config/nats.yaml") yield instance if block_given? end |