Module: WaterDrop::Producer::Testing
- Defined in:
- lib/waterdrop/producer/testing.rb
Overview
This module should only be used in test environments.
Requires karafka-rdkafka >= 0.23.1 which includes Rdkafka::Testing support.
This module is not auto-loaded by Zeitwerk and must be manually required.
Testing utilities for WaterDrop Producer instances.
This module provides methods for triggering and querying fatal errors on producers, which is useful for testing error handling and recovery logic (such as automatic producer reloading on fatal errors).
Instance Method Summary collapse
-
#fatal_error ⇒ Hash?
Checks if a fatal error has occurred on the underlying rdkafka producer.
-
#trigger_test_fatal_error(error_code, reason) ⇒ Integer
Triggers a test fatal error on the underlying rdkafka producer.
Instance Method Details
#fatal_error ⇒ Hash?
Checks if a fatal error has occurred on the underlying rdkafka producer.
This method queries librdkafka’s fatal error state to retrieve information about any fatal error that has occurred. Fatal errors are serious errors that prevent the producer from continuing normal operation.
93 94 95 96 |
# File 'lib/waterdrop/producer/testing.rb', line 93 def fatal_error ensure_testing_support! client.fatal_error end |
#trigger_test_fatal_error(error_code, reason) ⇒ Integer
Triggers a test fatal error on the underlying rdkafka producer.
This method uses librdkafka’s test error injection functionality to simulate fatal errors without requiring actual error conditions. This is particularly useful for testing WaterDrop’s fatal error handling and automatic reload logic.
66 67 68 69 |
# File 'lib/waterdrop/producer/testing.rb', line 66 def trigger_test_fatal_error(error_code, reason) ensure_testing_support! client.trigger_test_fatal_error(error_code, reason) end |