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
64 65 66 |
# File 'lib/waterdrop/clients/dummy.rb', line 64 def method_missing(*_args) self || super end |
Instance Method Details
#produce(topic:, partition: 0, **_args) ⇒ Handle
“Produces” the message
53 54 55 |
# File 'lib/waterdrop/clients/dummy.rb', line 53 def produce(topic:, partition: 0, **_args) Handle.new(topic.to_s, partition, @counters["#{topic}#{partition}"] += 1) end |
#respond_to_missing?(*_args) ⇒ Boolean
58 59 60 |
# File 'lib/waterdrop/clients/dummy.rb', line 58 def respond_to_missing?(*_args) true end |