Class: KafkaSession::Producer
- Inherits:
-
Object
- Object
- KafkaSession::Producer
- Defined in:
- lib/kafka_session/producer.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(name:, brokers:) ⇒ Producer
constructor
A new instance of Producer.
- #publish(messages:, topic:) ⇒ Object
Constructor Details
#initialize(name:, brokers:) ⇒ Producer
Returns a new instance of Producer.
7 8 9 10 11 12 |
# File 'lib/kafka_session/producer.rb', line 7 def initialize(name:, brokers:) @client = Kafka.new( seed_brokers: brokers, client_id: name ) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/kafka_session/producer.rb', line 5 def client @client end |
Instance Method Details
#publish(messages:, topic:) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/kafka_session/producer.rb', line 14 def publish(messages:, topic:) producer = client.producer .each do || producer.produce(, topic: topic) end producer. end |