Class: KafkaEventHub::Config
- Inherits:
-
Object
- Object
- KafkaEventHub::Config
- Defined in:
- lib/kafka_event_hub/config.rb
Direct Known Subclasses
Constant Summary collapse
- POLL_TIMEOUT =
ENV.fetch('KAFKA_POLL_TIMEOUT', 100).to_i
Instance Method Summary collapse
-
#consumer ⇒ Object
Returns an Rdkafka Consumer.
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
-
#producer ⇒ Object
Returns an Rdkafka Producer.
-
#topic ⇒ Object
The default topic to use.
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kafka_event_hub/config.rb', line 8 def initialize( = {}) @topic = ['topic'] || ENV.fetch('DEFAULT_TOPIC', 'default') settings = { "bootstrap.servers" => ENV.fetch('EVENT_HUB_NAMESPACE'), "security.protocol" => "SASL_SSL", "sasl.mechanism" => "PLAIN", "sasl.username" => "$ConnectionString", "sasl.password" => ENV.fetch('EVENT_HUB_URL'), "client.id" => ENV.fetch('APP_NAME'), } settings["group.id"] = "$#{ENV['EVENT_HUB_CONSUMER_GROUP']}" if ['consumer'] @kafka = Rdkafka::Config.new(settings) end |
Instance Method Details
#consumer ⇒ Object
Returns an Rdkafka Consumer
28 29 30 |
# File 'lib/kafka_event_hub/config.rb', line 28 def consumer @kafka.consumer end |
#producer ⇒ Object
Returns an Rdkafka Producer
23 24 25 |
# File 'lib/kafka_event_hub/config.rb', line 23 def producer @kafka.producer end |
#topic ⇒ Object
The default topic to use
33 34 35 |
# File 'lib/kafka_event_hub/config.rb', line 33 def topic @topic end |