Class: WaterDrop::Clients::Dummy::Handle

Inherits:
Rdkafka::Producer::DeliveryHandle
  • Object
show all
Defined in:
lib/waterdrop/clients/dummy.rb

Overview

::Rdkafka::Producer::DeliveryHandle object API compatible dummy object

Instance Method Summary collapse

Constructor Details

#initialize(topic, partition, offset) ⇒ Handle

Returns a new instance of Handle.

Parameters:

  • topic (String)

    topic where we want to dispatch message

  • partition (Integer)

    target partition

  • offset (Integer)

    offset assigned by our fake “Kafka”



16
17
18
19
20
# File 'lib/waterdrop/clients/dummy.rb', line 16

def initialize(topic, partition, offset)
  @topic = topic
  @partition = partition
  @offset = offset
end

Instance Method Details

#create_result::Rdkafka::Producer::DeliveryReport

Creates a delivery report with details where the message went

Returns:

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


33
34
35
36
37
38
39
# File 'lib/waterdrop/clients/dummy.rb', line 33

def create_result
  ::Rdkafka::Producer::DeliveryReport.new(
    @partition,
    @offset,
    @topic
  )
end

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

Does not wait, just creates the result

Parameters:

  • _args (Array)

    anything the wait handle would accept

Returns:

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


26
27
28
# File 'lib/waterdrop/clients/dummy.rb', line 26

def wait(*_args)
  create_result
end