waterdrop 2.8.13 → 2.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +16 -0
- data/.yard-lint.yml +174 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +17 -12
- data/lib/waterdrop/clients/dummy.rb +3 -0
- data/lib/waterdrop/helpers/counter.rb +1 -0
- data/lib/waterdrop/instrumentation/callbacks/delivery.rb +1 -1
- data/lib/waterdrop/instrumentation/callbacks/error.rb +1 -1
- data/lib/waterdrop/instrumentation/callbacks/statistics.rb +1 -1
- data/lib/waterdrop/middleware.rb +1 -0
- data/lib/waterdrop/producer/testing.rb +115 -0
- data/lib/waterdrop/producer.rb +6 -1
- data/lib/waterdrop/version.rb +1 -1
- data/lib/waterdrop.rb +2 -0
- data/waterdrop.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 57d1e899a312c47c5101a9029914468881e0ebb9437926767078c37f1ce1b4d1
|
|
4
|
+
data.tar.gz: 1767c8a557324bb5bccf93d79847705ecdbe1587d5ff97210597c41ee9cfa0d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5286d33cd2bf81f947ddb8c08c77b580aba8ff818f1e01431df36ae31dfbaf7984d3720e4463e1e9551379630fcfc6bcff161e5502d4b9bfa583c913ca050f7c
|
|
7
|
+
data.tar.gz: 7365a54e15b397d1c108db6949c6048c3c7e125b2063f2483e13c4ed6d38f961faaeed101a280cb5b9ef4c8d21335fb429e764c5939dbcf558eebc35aa21f3db
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -110,6 +110,21 @@ jobs:
|
|
|
110
110
|
- name: Run Coditsu
|
|
111
111
|
run: ./coditsu_script.sh
|
|
112
112
|
|
|
113
|
+
yard-lint:
|
|
114
|
+
timeout-minutes: 5
|
|
115
|
+
runs-on: ubuntu-latest
|
|
116
|
+
steps:
|
|
117
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
118
|
+
with:
|
|
119
|
+
fetch-depth: 0
|
|
120
|
+
- name: Set up Ruby
|
|
121
|
+
uses: ruby/setup-ruby@2a7b30092b0caf9c046252510f9273b4875f3db9 # v1.254.0
|
|
122
|
+
with:
|
|
123
|
+
ruby-version: '3.4'
|
|
124
|
+
bundler-cache: true
|
|
125
|
+
- name: Run yard-lint
|
|
126
|
+
run: bundle exec yard-lint lib/
|
|
127
|
+
|
|
113
128
|
ci-success:
|
|
114
129
|
name: CI Success
|
|
115
130
|
runs-on: ubuntu-latest
|
|
@@ -117,6 +132,7 @@ jobs:
|
|
|
117
132
|
needs:
|
|
118
133
|
- coditsu
|
|
119
134
|
- specs
|
|
135
|
+
- yard-lint
|
|
120
136
|
steps:
|
|
121
137
|
- name: Check all jobs passed
|
|
122
138
|
if: |
|
data/.yard-lint.yml
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# YARD-Lint Configuration
|
|
2
|
+
# See https://github.com/mensfeld/yard-lint for documentation
|
|
3
|
+
|
|
4
|
+
# Global settings for all validators
|
|
5
|
+
AllValidators:
|
|
6
|
+
# YARD command-line options (applied to all validators by default)
|
|
7
|
+
YardOptions:
|
|
8
|
+
- --private
|
|
9
|
+
- --protected
|
|
10
|
+
|
|
11
|
+
# Global file exclusion patterns
|
|
12
|
+
Exclude:
|
|
13
|
+
- '\.git'
|
|
14
|
+
- 'vendor/**/*'
|
|
15
|
+
- 'node_modules/**/*'
|
|
16
|
+
- 'spec/**/*'
|
|
17
|
+
- 'test/**/*'
|
|
18
|
+
|
|
19
|
+
# Exit code behavior (error, warning, convention, never)
|
|
20
|
+
FailOnSeverity: error
|
|
21
|
+
|
|
22
|
+
# Minimum documentation coverage percentage (0-100)
|
|
23
|
+
# Fails if coverage is below this threshold
|
|
24
|
+
MinCoverage: 100
|
|
25
|
+
|
|
26
|
+
# Diff mode settings
|
|
27
|
+
DiffMode:
|
|
28
|
+
# Default base ref for --diff (auto-detects main/master if not specified)
|
|
29
|
+
DefaultBaseRef: ~
|
|
30
|
+
|
|
31
|
+
# Documentation validators
|
|
32
|
+
Documentation/UndocumentedObjects:
|
|
33
|
+
Description: 'Checks for classes, modules, and methods without documentation.'
|
|
34
|
+
Enabled: true
|
|
35
|
+
Severity: error
|
|
36
|
+
ExcludedMethods:
|
|
37
|
+
- 'initialize/0' # Exclude parameter-less initialize
|
|
38
|
+
- '/^_/' # Exclude private methods (by convention)
|
|
39
|
+
|
|
40
|
+
Documentation/UndocumentedMethodArguments:
|
|
41
|
+
Description: 'Checks for method parameters without @param tags.'
|
|
42
|
+
Enabled: true
|
|
43
|
+
Severity: error
|
|
44
|
+
|
|
45
|
+
Documentation/UndocumentedBooleanMethods:
|
|
46
|
+
Description: 'Checks that question mark methods document their boolean return.'
|
|
47
|
+
Enabled: true
|
|
48
|
+
Severity: error
|
|
49
|
+
|
|
50
|
+
Documentation/UndocumentedOptions:
|
|
51
|
+
Description: 'Detects methods with options hash parameters but no @option tags.'
|
|
52
|
+
Enabled: true
|
|
53
|
+
Severity: error
|
|
54
|
+
|
|
55
|
+
Documentation/MarkdownSyntax:
|
|
56
|
+
Description: 'Detects common markdown syntax errors in documentation.'
|
|
57
|
+
Enabled: true
|
|
58
|
+
Severity: error
|
|
59
|
+
|
|
60
|
+
# Tags validators
|
|
61
|
+
Tags/Order:
|
|
62
|
+
Description: 'Enforces consistent ordering of YARD tags.'
|
|
63
|
+
Enabled: true
|
|
64
|
+
Severity: error
|
|
65
|
+
EnforcedOrder:
|
|
66
|
+
- param
|
|
67
|
+
- option
|
|
68
|
+
- return
|
|
69
|
+
- raise
|
|
70
|
+
- example
|
|
71
|
+
|
|
72
|
+
Tags/InvalidTypes:
|
|
73
|
+
Description: 'Validates type definitions in @param, @return, @option tags.'
|
|
74
|
+
Enabled: true
|
|
75
|
+
Severity: error
|
|
76
|
+
ValidatedTags:
|
|
77
|
+
- param
|
|
78
|
+
- option
|
|
79
|
+
- return
|
|
80
|
+
|
|
81
|
+
Tags/TypeSyntax:
|
|
82
|
+
Description: 'Validates YARD type syntax using YARD parser.'
|
|
83
|
+
Enabled: true
|
|
84
|
+
Severity: error
|
|
85
|
+
ValidatedTags:
|
|
86
|
+
- param
|
|
87
|
+
- option
|
|
88
|
+
- return
|
|
89
|
+
- yieldreturn
|
|
90
|
+
|
|
91
|
+
Tags/MeaninglessTag:
|
|
92
|
+
Description: 'Detects @param/@option tags on classes, modules, or constants.'
|
|
93
|
+
Enabled: true
|
|
94
|
+
Severity: error
|
|
95
|
+
CheckedTags:
|
|
96
|
+
- param
|
|
97
|
+
- option
|
|
98
|
+
InvalidObjectTypes:
|
|
99
|
+
- class
|
|
100
|
+
- module
|
|
101
|
+
- constant
|
|
102
|
+
|
|
103
|
+
Tags/CollectionType:
|
|
104
|
+
Description: 'Validates Hash collection syntax consistency.'
|
|
105
|
+
Enabled: true
|
|
106
|
+
Severity: error
|
|
107
|
+
EnforcedStyle: long # 'long' for Hash{K => V} (YARD standard), 'short' for {K => V}
|
|
108
|
+
ValidatedTags:
|
|
109
|
+
- param
|
|
110
|
+
- option
|
|
111
|
+
- return
|
|
112
|
+
- yieldreturn
|
|
113
|
+
|
|
114
|
+
Tags/TagTypePosition:
|
|
115
|
+
Description: 'Validates type annotation position in tags.'
|
|
116
|
+
Enabled: true
|
|
117
|
+
Severity: error
|
|
118
|
+
CheckedTags:
|
|
119
|
+
- param
|
|
120
|
+
- option
|
|
121
|
+
# EnforcedStyle: 'type_after_name' (YARD standard: @param name [Type])
|
|
122
|
+
# or 'type_first' (@param [Type] name)
|
|
123
|
+
EnforcedStyle: type_after_name
|
|
124
|
+
|
|
125
|
+
Tags/ApiTags:
|
|
126
|
+
Description: 'Enforces @api tags on public objects.'
|
|
127
|
+
Enabled: false # Opt-in validator
|
|
128
|
+
Severity: error
|
|
129
|
+
AllowedApis:
|
|
130
|
+
- public
|
|
131
|
+
- private
|
|
132
|
+
- internal
|
|
133
|
+
|
|
134
|
+
Tags/OptionTags:
|
|
135
|
+
Description: 'Requires @option tags for methods with options parameters.'
|
|
136
|
+
Enabled: true
|
|
137
|
+
Severity: error
|
|
138
|
+
|
|
139
|
+
# Warnings validators - catches YARD parser errors
|
|
140
|
+
Warnings/UnknownTag:
|
|
141
|
+
Description: 'Detects unknown YARD tags.'
|
|
142
|
+
Enabled: true
|
|
143
|
+
Severity: error
|
|
144
|
+
|
|
145
|
+
Warnings/UnknownDirective:
|
|
146
|
+
Description: 'Detects unknown YARD directives.'
|
|
147
|
+
Enabled: true
|
|
148
|
+
Severity: error
|
|
149
|
+
|
|
150
|
+
Warnings/InvalidTagFormat:
|
|
151
|
+
Description: 'Detects malformed tag syntax.'
|
|
152
|
+
Enabled: true
|
|
153
|
+
Severity: error
|
|
154
|
+
|
|
155
|
+
Warnings/InvalidDirectiveFormat:
|
|
156
|
+
Description: 'Detects malformed directive syntax.'
|
|
157
|
+
Enabled: true
|
|
158
|
+
Severity: error
|
|
159
|
+
|
|
160
|
+
Warnings/DuplicatedParameterName:
|
|
161
|
+
Description: 'Detects duplicate @param tags.'
|
|
162
|
+
Enabled: true
|
|
163
|
+
Severity: error
|
|
164
|
+
|
|
165
|
+
Warnings/UnknownParameterName:
|
|
166
|
+
Description: 'Detects @param tags for non-existent parameters.'
|
|
167
|
+
Enabled: true
|
|
168
|
+
Severity: error
|
|
169
|
+
|
|
170
|
+
# Semantic validators
|
|
171
|
+
Semantic/AbstractMethods:
|
|
172
|
+
Description: 'Ensures @abstract methods do not have real implementations.'
|
|
173
|
+
Enabled: true
|
|
174
|
+
Severity: error
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# WaterDrop changelog
|
|
2
2
|
|
|
3
|
+
## 2.8.14 (2025-11-14)
|
|
4
|
+
- [Fix] Fatal error replacement not working without exact error unwind from the fatal envelope
|
|
5
|
+
- [Testing] Add `WaterDrop::Producer::Testing` module for injecting and querying librdkafka fatal errors in tests.
|
|
6
|
+
- [Testing] Add `#trigger_test_fatal_error(error_code, reason)` method to simulate fatal errors without requiring actual broker-side conditions.
|
|
7
|
+
- [Testing] Add `#fatal_error` method to query current fatal error state for validation in tests.
|
|
8
|
+
- [Testing] Add comprehensive test coverage for fatal error injection, reload behavior, and event instrumentation with real librdkafka errors.
|
|
9
|
+
- [Change] Require `karafka-rdkafka` `>=` `0.23.1` due to error handling fixes.
|
|
10
|
+
|
|
3
11
|
## 2.8.13 (2025-10-31)
|
|
4
12
|
- [Enhancement] Make `fenced` error skip-reload behavior configurable via new `non_reloadable_errors` setting (defaults to `[:fenced]` for backward compatibility).
|
|
5
13
|
- [Enhancement] Add `producer.reload` event allowing config modification before reload to escape fencing loops (#706).
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
waterdrop (2.8.
|
|
4
|
+
waterdrop (2.8.14)
|
|
5
5
|
karafka-core (>= 2.4.9, < 3.0.0)
|
|
6
|
-
karafka-rdkafka (>= 0.
|
|
6
|
+
karafka-rdkafka (>= 0.23.1)
|
|
7
7
|
zeitwerk (~> 2.3)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
@@ -28,32 +28,32 @@ GEM
|
|
|
28
28
|
karafka-core (2.5.7)
|
|
29
29
|
karafka-rdkafka (>= 0.20.0)
|
|
30
30
|
logger (>= 1.6.0)
|
|
31
|
-
karafka-rdkafka (0.
|
|
32
|
-
ffi (~> 1.
|
|
31
|
+
karafka-rdkafka (0.23.1)
|
|
32
|
+
ffi (~> 1.17.1)
|
|
33
33
|
json (> 2.0)
|
|
34
34
|
logger
|
|
35
35
|
mini_portile2 (~> 2.6)
|
|
36
36
|
rake (> 12)
|
|
37
|
-
karafka-rdkafka (0.
|
|
38
|
-
ffi (~> 1.
|
|
37
|
+
karafka-rdkafka (0.23.1-aarch64-linux-gnu)
|
|
38
|
+
ffi (~> 1.17.1)
|
|
39
39
|
json (> 2.0)
|
|
40
40
|
logger
|
|
41
41
|
mini_portile2 (~> 2.6)
|
|
42
42
|
rake (> 12)
|
|
43
|
-
karafka-rdkafka (0.
|
|
44
|
-
ffi (~> 1.
|
|
43
|
+
karafka-rdkafka (0.23.1-arm64-darwin)
|
|
44
|
+
ffi (~> 1.17.1)
|
|
45
45
|
json (> 2.0)
|
|
46
46
|
logger
|
|
47
47
|
mini_portile2 (~> 2.6)
|
|
48
48
|
rake (> 12)
|
|
49
|
-
karafka-rdkafka (0.
|
|
50
|
-
ffi (~> 1.
|
|
49
|
+
karafka-rdkafka (0.23.1-x86_64-linux-gnu)
|
|
50
|
+
ffi (~> 1.17.1)
|
|
51
51
|
json (> 2.0)
|
|
52
52
|
logger
|
|
53
53
|
mini_portile2 (~> 2.6)
|
|
54
54
|
rake (> 12)
|
|
55
|
-
karafka-rdkafka (0.
|
|
56
|
-
ffi (~> 1.
|
|
55
|
+
karafka-rdkafka (0.23.1-x86_64-linux-musl)
|
|
56
|
+
ffi (~> 1.17.1)
|
|
57
57
|
json (> 2.0)
|
|
58
58
|
logger
|
|
59
59
|
mini_portile2 (~> 2.6)
|
|
@@ -82,6 +82,10 @@ GEM
|
|
|
82
82
|
simplecov-html (0.13.2)
|
|
83
83
|
simplecov_json_formatter (0.1.4)
|
|
84
84
|
warning (1.5.0)
|
|
85
|
+
yard (0.9.37)
|
|
86
|
+
yard-lint (1.2.3)
|
|
87
|
+
yard (~> 0.9)
|
|
88
|
+
zeitwerk (~> 2.6)
|
|
85
89
|
zeitwerk (2.7.3)
|
|
86
90
|
|
|
87
91
|
PLATFORMS
|
|
@@ -105,6 +109,7 @@ DEPENDENCIES
|
|
|
105
109
|
simplecov
|
|
106
110
|
warning
|
|
107
111
|
waterdrop!
|
|
112
|
+
yard-lint
|
|
108
113
|
zeitwerk (~> 2.7.0)
|
|
109
114
|
|
|
110
115
|
BUNDLED WITH
|
|
@@ -49,6 +49,9 @@ module WaterDrop
|
|
|
49
49
|
# @param topic [String, Symbol] topic where we want to dispatch message
|
|
50
50
|
# @param partition [Integer] target partition
|
|
51
51
|
# @param _args [Hash] remaining details that are ignored in the dummy mode
|
|
52
|
+
# @option _args [String] :payload message payload
|
|
53
|
+
# @option _args [String, nil] :key message key
|
|
54
|
+
# @option _args [Hash, nil] :headers message headers
|
|
52
55
|
# @return [Handle] delivery handle
|
|
53
56
|
def produce(topic:, partition: 0, **_args)
|
|
54
57
|
Handle.new(topic.to_s, partition, @counters["#{topic}#{partition}"] += 1)
|
|
@@ -22,7 +22,7 @@ module WaterDrop
|
|
|
22
22
|
|
|
23
23
|
private_constant :RD_KAFKA_RESP_PURGE_QUEUE, :RD_KAFKA_RESP_PURGE_INFLIGHT, :PURGE_ERRORS
|
|
24
24
|
|
|
25
|
-
# @param producer_id [String]
|
|
25
|
+
# @param producer_id [String]
|
|
26
26
|
# @param transactional [Boolean] is this handle for a transactional or regular producer
|
|
27
27
|
# @param monitor [WaterDrop::Instrumentation::Monitor] monitor we are using
|
|
28
28
|
def initialize(producer_id, transactional, monitor)
|
|
@@ -5,7 +5,7 @@ module WaterDrop
|
|
|
5
5
|
module Callbacks
|
|
6
6
|
# Callback that kicks in when error occurs and is published in a background thread
|
|
7
7
|
class Error
|
|
8
|
-
# @param producer_id [String]
|
|
8
|
+
# @param producer_id [String]
|
|
9
9
|
# @param client_name [String] rdkafka client name
|
|
10
10
|
# @param monitor [WaterDrop::Instrumentation::Monitor] monitor we are using
|
|
11
11
|
def initialize(producer_id, client_name, monitor)
|
|
@@ -10,7 +10,7 @@ module WaterDrop
|
|
|
10
10
|
# previous statistics emit but from the beginning of the process. We decorate it with diff
|
|
11
11
|
# of all the numeric values against the data from the previous callback emit
|
|
12
12
|
class Statistics
|
|
13
|
-
# @param producer_id [String]
|
|
13
|
+
# @param producer_id [String]
|
|
14
14
|
# @param client_name [String] rdkafka client name
|
|
15
15
|
# @param monitor [WaterDrop::Instrumentation::Monitor] monitor we are using
|
|
16
16
|
def initialize(producer_id, client_name, monitor)
|
data/lib/waterdrop/middleware.rb
CHANGED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module WaterDrop
|
|
4
|
+
class Producer
|
|
5
|
+
# Testing utilities for WaterDrop Producer instances.
|
|
6
|
+
#
|
|
7
|
+
# This module provides methods for triggering and querying fatal errors on producers,
|
|
8
|
+
# which is useful for testing error handling and recovery logic (such as automatic
|
|
9
|
+
# producer reloading on fatal errors).
|
|
10
|
+
#
|
|
11
|
+
# @note This module should only be used in test environments.
|
|
12
|
+
# @note Requires karafka-rdkafka >= 0.23.1 which includes Rdkafka::Testing support.
|
|
13
|
+
# @note This module is not auto-loaded by Zeitwerk and must be manually required.
|
|
14
|
+
#
|
|
15
|
+
# @example Including for a single producer instance
|
|
16
|
+
# require 'waterdrop/producer/testing'
|
|
17
|
+
#
|
|
18
|
+
# producer = WaterDrop::Producer.new
|
|
19
|
+
# producer.singleton_class.include(WaterDrop::Producer::Testing)
|
|
20
|
+
# producer.trigger_test_fatal_error(47, "Test producer fencing")
|
|
21
|
+
#
|
|
22
|
+
# @example Including for all producers in a test suite
|
|
23
|
+
# # In spec_helper.rb or test setup:
|
|
24
|
+
# require 'waterdrop/producer/testing'
|
|
25
|
+
#
|
|
26
|
+
# WaterDrop::Producer.include(WaterDrop::Producer::Testing)
|
|
27
|
+
#
|
|
28
|
+
# @example Testing idempotent producer reload on fatal error
|
|
29
|
+
# producer = WaterDrop::Producer.new do |config|
|
|
30
|
+
# config.kafka = { 'bootstrap.servers': 'localhost:9092' }
|
|
31
|
+
# config.reload_on_idempotent_fatal_error = true
|
|
32
|
+
# end
|
|
33
|
+
# producer.singleton_class.include(WaterDrop::Producer::Testing)
|
|
34
|
+
#
|
|
35
|
+
# # Trigger a fatal error that should cause reload
|
|
36
|
+
# producer.trigger_test_fatal_error(47, "Invalid producer epoch")
|
|
37
|
+
#
|
|
38
|
+
# # Produce should succeed after automatic reload
|
|
39
|
+
# producer.produce_sync(topic: 'test', payload: 'message')
|
|
40
|
+
#
|
|
41
|
+
# # Fatal error should be cleared after reload
|
|
42
|
+
# expect(producer.fatal_error).to be_nil
|
|
43
|
+
module Testing
|
|
44
|
+
# Triggers a test fatal error on the underlying rdkafka producer.
|
|
45
|
+
#
|
|
46
|
+
# This method uses librdkafka's test error injection functionality to simulate
|
|
47
|
+
# fatal errors without requiring actual error conditions. This is particularly
|
|
48
|
+
# useful for testing WaterDrop's fatal error handling and automatic reload logic.
|
|
49
|
+
#
|
|
50
|
+
# @param error_code [Integer] The librdkafka error code to trigger.
|
|
51
|
+
# Common error codes for testing:
|
|
52
|
+
# - 47 (RD_KAFKA_RESP_ERR_INVALID_PRODUCER_EPOCH) - Producer fencing
|
|
53
|
+
# - 64 (RD_KAFKA_RESP_ERR_INVALID_PRODUCER_ID_MAPPING) - Invalid producer ID
|
|
54
|
+
# @param reason [String] A descriptive reason for the error, used for debugging
|
|
55
|
+
# and logging purposes
|
|
56
|
+
#
|
|
57
|
+
# @return [Integer] Result code from rd_kafka_test_fatal_error (0 on success)
|
|
58
|
+
#
|
|
59
|
+
# @raise [RuntimeError] If the underlying rdkafka client doesn't support testing
|
|
60
|
+
#
|
|
61
|
+
# @example Trigger producer fencing error
|
|
62
|
+
# producer.trigger_test_fatal_error(47, "Test producer fencing scenario")
|
|
63
|
+
#
|
|
64
|
+
# @example Trigger invalid producer ID error
|
|
65
|
+
# producer.trigger_test_fatal_error(64, "Test invalid producer ID mapping")
|
|
66
|
+
def trigger_test_fatal_error(error_code, reason)
|
|
67
|
+
ensure_testing_support!
|
|
68
|
+
client.trigger_test_fatal_error(error_code, reason)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Checks if a fatal error has occurred on the underlying rdkafka producer.
|
|
72
|
+
#
|
|
73
|
+
# This method queries librdkafka's fatal error state to retrieve information
|
|
74
|
+
# about any fatal error that has occurred. Fatal errors are serious errors that
|
|
75
|
+
# prevent the producer from continuing normal operation.
|
|
76
|
+
#
|
|
77
|
+
# @return [Hash, nil] A hash containing error details if a fatal error occurred,
|
|
78
|
+
# or nil if no fatal error is present. The hash contains:
|
|
79
|
+
# - :error_code [Integer] The librdkafka error code
|
|
80
|
+
# - :error_string [String] Human-readable error description
|
|
81
|
+
#
|
|
82
|
+
# @example Check for fatal error
|
|
83
|
+
# if error = producer.fatal_error
|
|
84
|
+
# puts "Fatal error #{error[:error_code]}: #{error[:error_string]}"
|
|
85
|
+
# else
|
|
86
|
+
# puts "No fatal error present"
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
# @example Verify fatal error after triggering
|
|
90
|
+
# producer.trigger_test_fatal_error(47, "Test error")
|
|
91
|
+
# error = producer.fatal_error
|
|
92
|
+
# expect(error[:error_code]).to eq(47)
|
|
93
|
+
def fatal_error
|
|
94
|
+
ensure_testing_support!
|
|
95
|
+
client.fatal_error
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
# Ensures the underlying rdkafka client has testing support available.
|
|
101
|
+
# Automatically requires and includes Rdkafka::Testing if not already present.
|
|
102
|
+
#
|
|
103
|
+
# @return [void]
|
|
104
|
+
# @api private
|
|
105
|
+
def ensure_testing_support!
|
|
106
|
+
return if client.respond_to?(:trigger_test_fatal_error)
|
|
107
|
+
|
|
108
|
+
# Require the rdkafka testing module if not already loaded
|
|
109
|
+
require 'rdkafka/producer/testing' unless defined?(::Rdkafka::Testing)
|
|
110
|
+
|
|
111
|
+
client.singleton_class.include(::Rdkafka::Testing)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
data/lib/waterdrop/producer.rb
CHANGED
|
@@ -205,8 +205,13 @@ module WaterDrop
|
|
|
205
205
|
|
|
206
206
|
# Builds the variant alteration and returns it.
|
|
207
207
|
#
|
|
208
|
-
# @param args [
|
|
208
|
+
# @param args [Hash] variant configuration options
|
|
209
|
+
# @option args [Integer, nil] :max_wait_timeout alteration to max wait timeout or nil to use
|
|
210
|
+
# default
|
|
211
|
+
# @option args [Hash] :topic_config extra topic configuration that can be altered
|
|
212
|
+
# @option args [Boolean] :default is this a default variant or an altered one
|
|
209
213
|
# @return [WaterDrop::Producer::Variant] variant proxy to use with alterations
|
|
214
|
+
# @see https://karafka.io/docs/Librdkafka-Configuration/#topic-configuration-properties
|
|
210
215
|
def with(**args)
|
|
211
216
|
ensure_active!
|
|
212
217
|
|
data/lib/waterdrop/version.rb
CHANGED
data/lib/waterdrop.rb
CHANGED
|
@@ -42,5 +42,7 @@ loader = Zeitwerk::Loader.for_gem
|
|
|
42
42
|
loader.inflector.inflect('waterdrop' => 'WaterDrop')
|
|
43
43
|
# Do not load vendors instrumentation components. Those need to be required manually if needed
|
|
44
44
|
loader.ignore("#{__dir__}/waterdrop/instrumentation/vendors/**/*.rb")
|
|
45
|
+
# Do not load testing components. Those need to be required manually in test environments
|
|
46
|
+
loader.ignore("#{__dir__}/waterdrop/producer/testing.rb")
|
|
45
47
|
loader.setup
|
|
46
48
|
loader.eager_load
|
data/waterdrop.gemspec
CHANGED
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.licenses = %w[LGPL-3.0-only Commercial]
|
|
18
18
|
|
|
19
19
|
spec.add_dependency 'karafka-core', '>= 2.4.9', '< 3.0.0'
|
|
20
|
-
spec.add_dependency 'karafka-rdkafka', '>= 0.
|
|
20
|
+
spec.add_dependency 'karafka-rdkafka', '>= 0.23.1'
|
|
21
21
|
spec.add_dependency 'zeitwerk', '~> 2.3'
|
|
22
22
|
|
|
23
23
|
spec.required_ruby_version = '>= 3.2.0'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: waterdrop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.8.
|
|
4
|
+
version: 2.8.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maciej Mensfeld
|
|
@@ -35,14 +35,14 @@ dependencies:
|
|
|
35
35
|
requirements:
|
|
36
36
|
- - ">="
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 0.
|
|
38
|
+
version: 0.23.1
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - ">="
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 0.
|
|
45
|
+
version: 0.23.1
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: zeitwerk
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -77,6 +77,7 @@ files:
|
|
|
77
77
|
- ".rspec"
|
|
78
78
|
- ".ruby-gemset"
|
|
79
79
|
- ".ruby-version"
|
|
80
|
+
- ".yard-lint.yml"
|
|
80
81
|
- CHANGELOG.md
|
|
81
82
|
- Gemfile
|
|
82
83
|
- Gemfile.lock
|
|
@@ -122,6 +123,7 @@ files:
|
|
|
122
123
|
- lib/waterdrop/producer/idempotence.rb
|
|
123
124
|
- lib/waterdrop/producer/status.rb
|
|
124
125
|
- lib/waterdrop/producer/sync.rb
|
|
126
|
+
- lib/waterdrop/producer/testing.rb
|
|
125
127
|
- lib/waterdrop/producer/transactions.rb
|
|
126
128
|
- lib/waterdrop/producer/variant.rb
|
|
127
129
|
- lib/waterdrop/version.rb
|