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.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/clowder-common-ruby/types.rb', line 163

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.



160
161
162
# File 'lib/clowder-common-ruby/types.rb', line 160

def brokers
  @brokers
end

#topicsObject

Returns the value of attribute topics.



161
162
163
# File 'lib/clowder-common-ruby/types.rb', line 161

def topics
  @topics
end

Instance Method Details

#valid_keysObject



182
183
184
185
186
187
# File 'lib/clowder-common-ruby/types.rb', line 182

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