Class: ClowderCommonRuby::Config
- Defined in:
- lib/clowder-common-ruby/config.rb
Instance Attribute Summary
Attributes inherited from AppConfig
#database, #endpoints, #featureFlags, #inMemoryDb, #kafka, #logging, #metadata, #objectStore, #privateEndpoints
Class Method Summary collapse
-
.clowder_enabled? ⇒ Boolean
Check if clowder config’s ENV var is defined If true, svc is deployed by Clowder.
- .load(acg_config = ENV['ACG_CONFIG'] || 'test.json') ⇒ Object
Instance Method Summary collapse
-
#dependency_endpoints ⇒ Object
Nested map using [appName] for the public services of requested applications.
-
#initialize(acg_config) ⇒ Config
constructor
A new instance of Config.
-
#kafka_servers ⇒ Object
List of Kafka Broker URLs.
-
#kafka_topics ⇒ Object
Map of KafkaTopics using the requestedName as the key and the topic object as the value.
-
#object_buckets ⇒ Object
List of ObjectBuckets using the requestedName.
-
#private_dependency_endpoints ⇒ Object
nested map using [appName] for the private services of requested applications.
Methods inherited from AppConfig
Constructor Details
#initialize(acg_config) ⇒ Config
Returns a new instance of Config.
21 22 23 24 25 26 27 28 |
# File 'lib/clowder-common-ruby/config.rb', line 21 def initialize(acg_config) super(JSON.parse(File.read(acg_config))) kafka_servers kafka_topics object_buckets dependency_endpoints private_dependency_endpoints end |
Class Method Details
.clowder_enabled? ⇒ Boolean
Check if clowder config’s ENV var is defined If true, svc is deployed by Clowder
9 10 11 |
# File 'lib/clowder-common-ruby/config.rb', line 9 def self.clowder_enabled? !ENV['ACG_CONFIG'].nil? && ENV['ACG_CONFIG'] != "" end |
.load(acg_config = ENV['ACG_CONFIG'] || 'test.json') ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/clowder-common-ruby/config.rb', line 13 def self.load(acg_config = ENV['ACG_CONFIG'] || 'test.json') unless File.exist?(acg_config) raise "ERROR: #{acg_config} does not exist" end new(acg_config) end |
Instance Method Details
#dependency_endpoints ⇒ Object
Nested map using [appName] for the public services of requested applications.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/clowder-common-ruby/config.rb', line 63 def dependency_endpoints @dependency_endpoints ||= {}.tap do |endpts| endpoints.each do |endpoint| next if endpoint.app.nil? || endpoint.name.nil? endpts[endpoint.app] = {} unless endpts.include?(endpoint.app) endpts[endpoint.app][endpoint.name] = endpoint end end end |
#kafka_servers ⇒ Object
List of Kafka Broker URLs.
31 32 33 34 35 36 37 |
# File 'lib/clowder-common-ruby/config.rb', line 31 def kafka_servers @kafka_servers ||= [].tap do |servers| kafka.brokers.each do |broker| servers << "{#{broker.hostname}}:{#{broker.port}}" end end end |
#kafka_topics ⇒ Object
Map of KafkaTopics using the requestedName as the key and the topic object as the value.
40 41 42 43 44 45 46 47 48 |
# File 'lib/clowder-common-ruby/config.rb', line 40 def kafka_topics @kafka_topics ||= {}.tap do |topics| kafka.topics.each do |topic| next if topic.requestedName.nil? topics[topic.requestedName] = topic end end end |
#object_buckets ⇒ Object
List of ObjectBuckets using the requestedName
51 52 53 54 55 56 57 58 59 |
# File 'lib/clowder-common-ruby/config.rb', line 51 def object_buckets @object_buckets ||= {}.tap do |buckets| objectStore.buckets.each do |bucket| next if bucket.requestedName.nil? buckets[bucket.requestedName] = bucket end end end |
#private_dependency_endpoints ⇒ Object
nested map using [appName]
for the private services of requested applications.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/clowder-common-ruby/config.rb', line 76 def private_dependency_endpoints @private_dependency_endpoints ||= {}.tap do |priv_endpts| privateEndpoints.each do |endpoint| next if endpoint.app.nil? || endpoint.name.nil? priv_endpts[endpoint.app] = {} unless priv_endpts.include?(endpoint.app) priv_endpts[endpoint.app][endpoint.name] = endpoint end end end |