Class: Sbmt::KafkaConsumer::Config

Inherits:
Anyway::Config
  • Object
show all
Defined in:
lib/sbmt/kafka_consumer/config.rb

Defined Under Namespace

Classes: Auth, Consumer, ConsumerGroup, Deserializer, Kafka, Metrics, Probes, Topic

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.coerce_to(struct) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/sbmt/kafka_consumer/config.rb', line 7

def coerce_to(struct)
  lambda do |raw_attrs|
    struct.new(**raw_attrs)
  rescue Dry::Types::SchemaError => e
    raise_validation_error "cannot parse #{struct}: #{e.message}"
  end
end

.coerce_to_array_of(struct) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/sbmt/kafka_consumer/config.rb', line 15

def coerce_to_array_of(struct)
  lambda do |raw_attrs|
    raw_attrs.keys.map do |obj_title|
      coerce_to(struct)
        .call(**raw_attrs.fetch(obj_title)
                        .merge(id: obj_title))
    end
  end
end

Instance Method Details

#to_kafka_optionsObject



60
61
62
63
64
65
66
# File 'lib/sbmt/kafka_consumer/config.rb', line 60

def to_kafka_options
  {
    "partition.assignment.strategy": partition_assignment_strategy
  }.compact
    .merge(kafka.to_kafka_options)
    .merge(auth.to_kafka_options)
end