Class: WaterDrop::Producer::DummyClient

Inherits:
Object
  • Object
show all
Defined in:
lib/waterdrop/producer/dummy_client.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

Instance Method Summary collapse

Constructor Details

#initializeDummyClient

Returns dummy instance.



9
10
11
# File 'lib/waterdrop/producer/dummy_client.rb', line 9

def initialize
  @counter = -1
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*_args) ⇒ self

Returns self for chaining cases

Parameters:

  • _args (Object)

    anything really, this dummy is suppose to support anything

Returns:

  • (self)

    returns self for chaining cases



27
28
29
# File 'lib/waterdrop/producer/dummy_client.rb', line 27

def method_missing(*_args)
  self || super
end

Instance Method Details

#respond_to_missing?(*_args) ⇒ Boolean

Parameters:

  • _args (Object)

    anything really, this dummy is suppose to support anything

Returns:

  • (Boolean)


21
22
23
# File 'lib/waterdrop/producer/dummy_client.rb', line 21

def respond_to_missing?(*_args)
  true
end

#wait(*_args) ⇒ ::Rdkafka::Producer::DeliveryReport

Dummy method for returning the delivery report

Parameters:

  • _args (Object)

    anything that the delivery handle accepts

Returns:

  • (::Rdkafka::Producer::DeliveryReport)


16
17
18
# File 'lib/waterdrop/producer/dummy_client.rb', line 16

def wait(*_args)
  ::Rdkafka::Producer::DeliveryReport.new(0, @counter += 1)
end