class ClowderCommonRuby::Config

Public Class Methods

clowder_enabled?() click to toggle source

Check if clowder config's ENV var is defined If true, svc is deployed by Clowder

# 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') click to toggle source
# 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
new(acg_config) click to toggle source
Calls superclass method
# 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

Public Instance Methods

dependency_endpoints() click to toggle source

Nested map using [appName] for the public services of requested applications.

# 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() click to toggle source

List of Kafka Broker URLs.

# 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() click to toggle source

Map of KafkaTopics using the requestedName as the key and the topic object as the value.

# 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() click to toggle source

List of ObjectBuckets using the requestedName

# 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() click to toggle source

nested map using [appName]

for the private services of requested applications.
# 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