Class: Racecar::DeliveryCallback
- Inherits:
-
Object
- Object
- Racecar::DeliveryCallback
- Defined in:
- lib/racecar/delivery_callback.rb
Instance Attribute Summary collapse
-
#instrumenter ⇒ Object
readonly
Returns the value of attribute instrumenter.
Instance Method Summary collapse
- #call(delivery_report) ⇒ Object
-
#initialize(instrumenter:) ⇒ DeliveryCallback
constructor
A new instance of DeliveryCallback.
Constructor Details
#initialize(instrumenter:) ⇒ DeliveryCallback
Returns a new instance of DeliveryCallback.
7 8 9 |
# File 'lib/racecar/delivery_callback.rb', line 7 def initialize(instrumenter:) @instrumenter = instrumenter end |
Instance Attribute Details
#instrumenter ⇒ Object (readonly)
Returns the value of attribute instrumenter.
5 6 7 |
# File 'lib/racecar/delivery_callback.rb', line 5 def instrumenter @instrumenter end |
Instance Method Details
#call(delivery_report) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/racecar/delivery_callback.rb', line 11 def call(delivery_report) if delivery_report.error.to_i.zero? payload = { offset: delivery_report.offset, partition: delivery_report.partition } instrumenter.instrument("acknowledged_message", payload) else payload = { partition: delivery_report.partition, exception: delivery_report.error } instrumenter.instrument("produce_delivery_error", payload) end end |