class WaterDrop::Clients::Dummy

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.

Public Class Methods

new(_producer) click to toggle source

@param _producer [WaterDrop::Producer] @return [Dummy] dummy instance

# File lib/waterdrop/clients/dummy.rb, line 44
def initialize(_producer)
  @counters = Hash.new { |h, k| h[k] = -1 }
end

Public Instance Methods

method_missing(*_args) click to toggle source

@param _args [Object] anything really, this dummy is suppose to support anything @return [self] returns self for chaining cases

Calls superclass method
# File lib/waterdrop/clients/dummy.rb, line 64
def method_missing(*_args)
  self || super
end
produce(topic:, partition: 0, **_args) click to toggle source

“Produces” the message @param topic [String, Symbol] topic where we want to dispatch message @param partition [Integer] target partition @param _args [Hash] remaining details that are ignored in the dummy mode @return [Handle] delivery handle

# 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) click to toggle source

@param _args [Object] anything really, this dummy is suppose to support anything

# File lib/waterdrop/clients/dummy.rb, line 58
def respond_to_missing?(*_args)
  true
end