Class: KafkaProducer
- Inherits:
-
Object
- Object
- KafkaProducer
- Defined in:
- lib/kafka_producer.rb
Instance Method Summary collapse
- #get_kafka_instance ⇒ Object
-
#initialize ⇒ KafkaProducer
constructor
A new instance of KafkaProducer.
- #publish_to_topic(topic, message) ⇒ Object
Constructor Details
#initialize ⇒ KafkaProducer
Returns a new instance of KafkaProducer.
3 4 5 |
# File 'lib/kafka_producer.rb', line 3 def initialize @configs = YAML.load_file("#{Rails.root}/config/ruby_kafka_retry.yml")[Rails.env] end |
Instance Method Details
#get_kafka_instance ⇒ Object
7 8 9 |
# File 'lib/kafka_producer.rb', line 7 def get_kafka_instance Kafka.new(@configs["brokers"], client_id: @configs["client_id"], ssl_ca_certs_from_system: @configs["ssl_ca_certs_from_system"]) end |
#publish_to_topic(topic, message) ⇒ Object
11 12 13 14 |
# File 'lib/kafka_producer.rb', line 11 def publish_to_topic(topic, ) kafka = get_kafka_instance kafka.(.to_json, topic: topic) end |