Class: ClowderCommonRuby::KafkaConfig

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/clowder-common-ruby/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ KafkaConfig

Returns a new instance of KafkaConfig.



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/clowder-common-ruby/types.rb', line 171

def initialize(attributes)
  super
  raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))

  attributes = attributes.each_with_object({}) do |(k, v), h|
    warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
    h[k.to_sym] = v
  end

  @brokers = []
  attributes.fetch(:brokers, []).each do |attr|
    @brokers << BrokerConfig.new(attr)
  end
  @topics = []
  attributes.fetch(:topics, []).each do |attr|
    @topics << TopicConfig.new(attr)
  end
end

Instance Attribute Details

#brokersObject

Returns the value of attribute brokers.



168
169
170
# File 'lib/clowder-common-ruby/types.rb', line 168

def brokers
  @brokers
end

#topicsObject

Returns the value of attribute topics.



169
170
171
# File 'lib/clowder-common-ruby/types.rb', line 169

def topics
  @topics
end

Instance Method Details

#valid_keysObject



190
191
192
193
194
195
# File 'lib/clowder-common-ruby/types.rb', line 190

def valid_keys
  [].tap do |keys|
    keys << :brokers
    keys << :topics
  end
end