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.
-
#queue_size ⇒ Integer
(also: #queue_length)
Returns 0 as dummy client doesn’t queue any real messages.
- #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
76 77 78 |
# File 'lib/waterdrop/clients/dummy.rb', line 76 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 |
#queue_size ⇒ Integer Also known as: queue_length
Returns 0 as dummy client doesn’t queue any real messages
63 64 65 |
# File 'lib/waterdrop/clients/dummy.rb', line 63 def queue_size 0 end |
#respond_to_missing?(*_args) ⇒ Boolean
70 71 72 |
# File 'lib/waterdrop/clients/dummy.rb', line 70 def respond_to_missing?(*_args) true end |