Class: WaterDrop::Clients::Dummy

Inherits:
Object
  • Object
show all
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.

Direct Known Subclasses

Buffered

Instance Method Summary collapse

Constructor Details

#initialize(_producer) ⇒ Dummy

Returns dummy instance.

Parameters:



12
13
14
# File 'lib/waterdrop/clients/dummy.rb', line 12

def initialize(_producer)
  @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



30
31
32
# File 'lib/waterdrop/clients/dummy.rb', line 30

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)


24
25
26
# File 'lib/waterdrop/clients/dummy.rb', line 24

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)


19
20
21
# File 'lib/waterdrop/clients/dummy.rb', line 19

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