Class: WaterDrop::Clients::Dummy
- Inherits:
-
Object
- Object
- WaterDrop::Clients::Dummy
- Defined in:
- lib/waterdrop/clients/dummy.rb
Overview
A dummy client that is supposed to be used instead of Rdkafka::Producer in case we don’t want to dispatch anything to Kafka.
It does not store anything and just ignores messages. It does however return proper delivery handle that can be materialized into a report.
Direct Known Subclasses
Defined Under Namespace
Classes: Handle
Instance Method Summary collapse
-
#initialize(_producer) ⇒ Dummy
constructor
Dummy instance.
-
#method_missing(*_args) ⇒ self
Returns self for chaining cases.
-
#produce(topic:, partition: 0, **_args) ⇒ Handle
“Produces” the message.
-
#respond_to_missing?(*_args) ⇒ Boolean
Constructor Details
#initialize(_producer) ⇒ Dummy
Returns dummy instance.
44 45 46 |
# File 'lib/waterdrop/clients/dummy.rb', line 44 def initialize(_producer) @counters = Hash.new { |h, k| h[k] = -1 } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*_args) ⇒ self
Returns self for chaining cases
67 68 69 |
# File 'lib/waterdrop/clients/dummy.rb', line 67 def method_missing(*_args) self || super end |
Instance Method Details
#produce(topic:, partition: 0, **_args) ⇒ Handle
“Produces” the message
56 57 58 |
# File 'lib/waterdrop/clients/dummy.rb', line 56 def produce(topic:, partition: 0, **_args) Handle.new(topic.to_s, partition, @counters["#{topic}#{partition}"] += 1) end |
#respond_to_missing?(*_args) ⇒ Boolean
61 62 63 |
# File 'lib/waterdrop/clients/dummy.rb', line 61 def respond_to_missing?(*_args) true end |