karafka-core 2.5.2 → 2.5.8
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 +38 -28
- data/.github/workflows/push.yml +3 -3
- data/.github/workflows/trigger-wiki-refresh.yml +30 -0
- data/.github/workflows/verify-action-pins.yml +2 -2
- data/.ruby-version +1 -1
- data/.yard-lint.yml +174 -0
- data/CHANGELOG.md +29 -3
- data/Gemfile +2 -2
- data/Gemfile.lock +43 -8
- data/karafka-core.gemspec +3 -4
- data/lib/karafka/core/configurable/node.rb +56 -18
- data/lib/karafka/core/configurable.rb +7 -23
- data/lib/karafka/core/contractable/contract.rb +4 -7
- data/lib/karafka/core/contractable/result.rb +6 -1
- data/lib/karafka/core/helpers/rspec_locator.rb +1 -1
- data/lib/karafka/core/monitoring/event.rb +1 -1
- data/lib/karafka/core/monitoring/monitor.rb +7 -11
- data/lib/karafka/core/monitoring/notifications.rb +25 -7
- data/lib/karafka/core/monitoring/statistics_decorator.rb +17 -5
- data/lib/karafka/core/version.rb +1 -1
- data/lib/karafka-core.rb +26 -36
- metadata +7 -13
- data/.diffend.yml +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0566f7af7e0bc6845a4078f1a43399caffde5569134931fa2b3dd7eebff80acf
|
|
4
|
+
data.tar.gz: 07cc05d3d190137e9564e3e55337182642c714ab3b1a239b4197c68e45e23d8c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e0fa31222e15c878b2bd09e5e6b1e5c2777df35d5d2e4baff9e82fdf68aac1e9937bc01055170f7845d438f7f7763c95e6d6f60848969ff08430d3fa3ccdc8dc
|
|
7
|
+
data.tar.gz: 98ff20883506dbdece28f8de46f6fd67895a8bb3fcc343ca1d9d753b1e87f6acf9bc0ae31ce7799b3c6c2def15d88edd696f3f55d51eca5a88f111d1915f44be
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -6,9 +6,7 @@ concurrency:
|
|
|
6
6
|
|
|
7
7
|
on:
|
|
8
8
|
pull_request:
|
|
9
|
-
branches: [
|
|
10
|
-
push:
|
|
11
|
-
branches: [ main, master ]
|
|
9
|
+
branches: [ master ]
|
|
12
10
|
schedule:
|
|
13
11
|
- cron: '0 1 * * *'
|
|
14
12
|
|
|
@@ -19,20 +17,19 @@ jobs:
|
|
|
19
17
|
specs:
|
|
20
18
|
timeout-minutes: 15
|
|
21
19
|
runs-on: ubuntu-latest
|
|
22
|
-
needs: diffend
|
|
23
20
|
strategy:
|
|
24
21
|
fail-fast: false
|
|
25
22
|
matrix:
|
|
26
23
|
ruby:
|
|
24
|
+
- '4.0.0-preview2'
|
|
27
25
|
- '3.4'
|
|
28
26
|
- '3.3'
|
|
29
27
|
- '3.2'
|
|
30
|
-
- '3.1'
|
|
31
28
|
include:
|
|
32
29
|
- ruby: '3.4'
|
|
33
30
|
coverage: 'true'
|
|
34
31
|
steps:
|
|
35
|
-
- uses: actions/checkout@
|
|
32
|
+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
36
33
|
with:
|
|
37
34
|
fetch-depth: 0
|
|
38
35
|
|
|
@@ -40,10 +37,11 @@ jobs:
|
|
|
40
37
|
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
|
41
38
|
|
|
42
39
|
- name: Set up Ruby
|
|
43
|
-
uses: ruby/setup-ruby@
|
|
40
|
+
uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
|
|
44
41
|
with:
|
|
45
42
|
ruby-version: ${{matrix.ruby}}
|
|
46
43
|
bundler: 'latest'
|
|
44
|
+
self-hosted: false
|
|
47
45
|
|
|
48
46
|
- name: Install latest bundler
|
|
49
47
|
run: |
|
|
@@ -61,33 +59,13 @@ jobs:
|
|
|
61
59
|
GITHUB_COVERAGE: ${{matrix.coverage}}
|
|
62
60
|
run: bundle exec rspec
|
|
63
61
|
|
|
64
|
-
diffend:
|
|
65
|
-
timeout-minutes: 5
|
|
66
|
-
runs-on: ubuntu-latest
|
|
67
|
-
strategy:
|
|
68
|
-
fail-fast: false
|
|
69
|
-
steps:
|
|
70
|
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
71
|
-
with:
|
|
72
|
-
fetch-depth: 0
|
|
73
|
-
- name: Set up Ruby
|
|
74
|
-
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
|
|
75
|
-
with:
|
|
76
|
-
ruby-version: 3.4
|
|
77
|
-
- name: Install latest bundler
|
|
78
|
-
run: gem install bundler --no-document
|
|
79
|
-
- name: Install Diffend plugin
|
|
80
|
-
run: bundle plugin install diffend
|
|
81
|
-
- name: Bundle Secure
|
|
82
|
-
run: bundle secure
|
|
83
|
-
|
|
84
62
|
coditsu:
|
|
85
63
|
timeout-minutes: 5
|
|
86
64
|
runs-on: ubuntu-latest
|
|
87
65
|
strategy:
|
|
88
66
|
fail-fast: false
|
|
89
67
|
steps:
|
|
90
|
-
- uses: actions/checkout@
|
|
68
|
+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
91
69
|
with:
|
|
92
70
|
fetch-depth: 0
|
|
93
71
|
- name: Download Coditsu script
|
|
@@ -104,3 +82,35 @@ jobs:
|
|
|
104
82
|
fi
|
|
105
83
|
- name: Run Coditsu
|
|
106
84
|
run: ./coditsu_script.sh
|
|
85
|
+
|
|
86
|
+
yard-lint:
|
|
87
|
+
timeout-minutes: 5
|
|
88
|
+
runs-on: ubuntu-latest
|
|
89
|
+
steps:
|
|
90
|
+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
91
|
+
with:
|
|
92
|
+
fetch-depth: 0
|
|
93
|
+
- name: Set up Ruby
|
|
94
|
+
uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
|
|
95
|
+
with:
|
|
96
|
+
ruby-version: '3.4.7'
|
|
97
|
+
bundler-cache: true
|
|
98
|
+
- name: Run yard-lint
|
|
99
|
+
run: bundle exec yard-lint lib/
|
|
100
|
+
|
|
101
|
+
ci-success:
|
|
102
|
+
name: CI Success
|
|
103
|
+
runs-on: ubuntu-latest
|
|
104
|
+
if: always()
|
|
105
|
+
needs:
|
|
106
|
+
- coditsu
|
|
107
|
+
- specs
|
|
108
|
+
- yard-lint
|
|
109
|
+
steps:
|
|
110
|
+
- name: Check all jobs passed
|
|
111
|
+
if: |
|
|
112
|
+
contains(needs.*.result, 'failure') ||
|
|
113
|
+
contains(needs.*.result, 'cancelled') ||
|
|
114
|
+
contains(needs.*.result, 'skipped')
|
|
115
|
+
run: exit 1
|
|
116
|
+
- run: echo "All CI checks passed!"
|
data/.github/workflows/push.yml
CHANGED
|
@@ -19,12 +19,12 @@ jobs:
|
|
|
19
19
|
id-token: write
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
23
23
|
with:
|
|
24
24
|
fetch-depth: 0
|
|
25
25
|
|
|
26
26
|
- name: Set up Ruby
|
|
27
|
-
uses: ruby/setup-ruby@
|
|
27
|
+
uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
|
|
28
28
|
with:
|
|
29
29
|
bundler-cache: false
|
|
30
30
|
|
|
@@ -32,4 +32,4 @@ jobs:
|
|
|
32
32
|
run: |
|
|
33
33
|
bundle install --jobs 4 --retry 3
|
|
34
34
|
|
|
35
|
-
- uses: rubygems/release-gem@
|
|
35
|
+
- uses: rubygems/release-gem@1c162a739e8b4cb21a676e97b087e8268d8fc40b # v1.1.2
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Trigger Wiki Refresh
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
push:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
trigger-wiki-refresh:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment: wiki-trigger
|
|
13
|
+
if: github.repository_owner == 'karafka'
|
|
14
|
+
steps:
|
|
15
|
+
- name: Trigger wiki refresh
|
|
16
|
+
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
|
|
17
|
+
with:
|
|
18
|
+
token: ${{ secrets.WIKI_REPO_TOKEN }}
|
|
19
|
+
repository: karafka/wiki
|
|
20
|
+
event-type: sync-trigger
|
|
21
|
+
client-payload: |
|
|
22
|
+
{
|
|
23
|
+
"repository": "${{ github.repository }}",
|
|
24
|
+
"event_name": "${{ github.event_name }}",
|
|
25
|
+
"release_tag": "${{ github.event.release.tag_name || '' }}",
|
|
26
|
+
"release_name": "${{ github.event.release.name || '' }}",
|
|
27
|
+
"commit_sha": "${{ github.sha }}",
|
|
28
|
+
"commit_message": "Trigger Wiki Refresh",
|
|
29
|
+
"triggered_by": "${{ github.actor }}"
|
|
30
|
+
}
|
|
@@ -4,10 +4,10 @@ on:
|
|
|
4
4
|
paths:
|
|
5
5
|
- '.github/workflows/**'
|
|
6
6
|
jobs:
|
|
7
|
-
|
|
7
|
+
verify_action_pins:
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
9
|
steps:
|
|
10
|
-
- uses: actions/checkout@
|
|
10
|
+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
11
11
|
- name: Check SHA pins
|
|
12
12
|
run: |
|
|
13
13
|
if grep -E -r "uses: .*/.*@(v[0-9]+|main|master)($|[[:space:]]|$)" --include="*.yml" --include="*.yaml" .github/workflows/ | grep -v "#"; then
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.4.
|
|
1
|
+
3.4.7
|
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: 98.0
|
|
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,31 @@
|
|
|
1
1
|
# Karafka Core Changelog
|
|
2
2
|
|
|
3
|
+
## 2.5.8 (2025-11-23)
|
|
4
|
+
- [Enhancement] Memoize `StatisticsDecorator` suffix keys to reduce string allocations (#268).
|
|
5
|
+
|
|
6
|
+
## 2.5.7 (2025-09-28)
|
|
7
|
+
- [Enhancement] Optimize `Node#deep_dup` to reduce array allocations during configuration deep copying.
|
|
8
|
+
- [Enhancement] Optimize `Result#initialize` to use shared `EMPTY_HASH` constant for successful validations.
|
|
9
|
+
- [Enhancement] Optimize `StatisticsDecorator#append` string concatenation to reduce allocations.
|
|
10
|
+
- [Enhancement] Optimize `Notifications#instrument` payload handling to avoid unnecessary hash merges for empty payloads.
|
|
11
|
+
- **[EOL]** Remove Ruby 3.1 support due to EOL.
|
|
12
|
+
|
|
13
|
+
## 2.5.6 (2025-09-02)
|
|
14
|
+
- [Change] Normalize how libs and dependencies are required (no functional change for the end user)
|
|
15
|
+
- [Change] Set minimum `karafka-rdkafka` on `0.20.0` to support new features and allow for open range as both `waterdrop` and `karafka` manage this.
|
|
16
|
+
|
|
17
|
+
## 2.5.5 (2025-08-04)
|
|
18
|
+
- [Enhancement] Remove reliance on `Set` class.
|
|
19
|
+
|
|
20
|
+
## 2.5.4 (2025-08-04)
|
|
21
|
+
- [Fix] Fix old regression on misbehaviour when Object methods are overwritten.
|
|
22
|
+
|
|
23
|
+
## 2.5.3 (2025-08-04)
|
|
24
|
+
- [Enhancement] Optimize code to mitigate the Ruby performance warning from `Karafka::Core::Configurable::Node` (#208)
|
|
25
|
+
- [Enhancement] Raise errors on detected Ruby warnings.
|
|
26
|
+
- [Change] Remove unused Ruby 2.7 code.
|
|
27
|
+
- [Change] Remove `funding_uri` from the gemspec to minimize double-funding info.
|
|
28
|
+
|
|
3
29
|
## 2.5.2 (2025-06-11)
|
|
4
30
|
- [Enhancement] Support `#unsubscribe`.
|
|
5
31
|
- [Enhancement] Allow for providing a root scope path for error keys.
|
|
@@ -32,7 +58,7 @@
|
|
|
32
58
|
- [Change] Allow `karafka-rdkafka` `0.18.0`.
|
|
33
59
|
|
|
34
60
|
## 2.4.5 (2024-11-19)
|
|
35
|
-
- **[
|
|
61
|
+
- **[EOL]** Drop Ruby `3.0` support according to the EOL schedule.
|
|
36
62
|
- [Enhancement] Support listeners inspection via `#listeners`.
|
|
37
63
|
- [Fix] Restore `#available_events` notifications bus method.
|
|
38
64
|
- [Change] Set minimum `karafka-rdkafka` on `0.17.6` to support new features.
|
|
@@ -55,7 +81,7 @@
|
|
|
55
81
|
- [Enhancement] Allow clearing one event type (dorner).
|
|
56
82
|
|
|
57
83
|
## 2.4.0 (2024-04-26)
|
|
58
|
-
- **[
|
|
84
|
+
- **[EOL]** Drop Ruby `2.7` support.
|
|
59
85
|
- [Enhancement] Provide necessary alterations for custom oauth token callbacks to operate.
|
|
60
86
|
- [Change] Set minimum `karafka-rdkafka` on `0.15.0` to support new features.
|
|
61
87
|
|
|
@@ -70,7 +96,7 @@
|
|
|
70
96
|
- [Enhancement] Set backtrace for errors propagated via the errors callbacks.
|
|
71
97
|
|
|
72
98
|
## 2.2.5 (2023-10-31)
|
|
73
|
-
- [
|
|
99
|
+
- **[EOL]** Drop support for Ruby 2.6 due to incompatibilities in usage of `ObjectSpace::WeakMap`
|
|
74
100
|
- [Change] Set minimum `karafka-rdkafka` on `0.13.8` to support consumer `#position`.
|
|
75
101
|
|
|
76
102
|
## 2.2.4 (2023-10-25)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
karafka-core (2.5.
|
|
5
|
-
karafka-rdkafka (>= 0.
|
|
4
|
+
karafka-core (2.5.8)
|
|
5
|
+
karafka-rdkafka (>= 0.20.0)
|
|
6
6
|
logger (>= 1.6.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
@@ -22,32 +22,65 @@ GEM
|
|
|
22
22
|
ffi (1.17.2-x86_64-darwin)
|
|
23
23
|
ffi (1.17.2-x86_64-linux-gnu)
|
|
24
24
|
ffi (1.17.2-x86_64-linux-musl)
|
|
25
|
-
|
|
25
|
+
json (2.15.1)
|
|
26
|
+
karafka-rdkafka (0.22.2)
|
|
26
27
|
ffi (~> 1.15)
|
|
28
|
+
json (> 2.0)
|
|
29
|
+
logger
|
|
30
|
+
mini_portile2 (~> 2.6)
|
|
31
|
+
rake (> 12)
|
|
32
|
+
karafka-rdkafka (0.22.2-aarch64-linux-gnu)
|
|
33
|
+
ffi (~> 1.15)
|
|
34
|
+
json (> 2.0)
|
|
35
|
+
logger
|
|
36
|
+
mini_portile2 (~> 2.6)
|
|
37
|
+
rake (> 12)
|
|
38
|
+
karafka-rdkafka (0.22.2-arm64-darwin)
|
|
39
|
+
ffi (~> 1.15)
|
|
40
|
+
json (> 2.0)
|
|
41
|
+
logger
|
|
42
|
+
mini_portile2 (~> 2.6)
|
|
43
|
+
rake (> 12)
|
|
44
|
+
karafka-rdkafka (0.22.2-x86_64-linux-gnu)
|
|
45
|
+
ffi (~> 1.15)
|
|
46
|
+
json (> 2.0)
|
|
47
|
+
logger
|
|
48
|
+
mini_portile2 (~> 2.6)
|
|
49
|
+
rake (> 12)
|
|
50
|
+
karafka-rdkafka (0.22.2-x86_64-linux-musl)
|
|
51
|
+
ffi (~> 1.15)
|
|
52
|
+
json (> 2.0)
|
|
53
|
+
logger
|
|
27
54
|
mini_portile2 (~> 2.6)
|
|
28
55
|
rake (> 12)
|
|
29
56
|
logger (1.7.0)
|
|
30
57
|
mini_portile2 (2.8.9)
|
|
31
58
|
rake (13.3.0)
|
|
32
|
-
rspec (3.13.
|
|
59
|
+
rspec (3.13.2)
|
|
33
60
|
rspec-core (~> 3.13.0)
|
|
34
61
|
rspec-expectations (~> 3.13.0)
|
|
35
62
|
rspec-mocks (~> 3.13.0)
|
|
36
|
-
rspec-core (3.13.
|
|
63
|
+
rspec-core (3.13.6)
|
|
37
64
|
rspec-support (~> 3.13.0)
|
|
38
65
|
rspec-expectations (3.13.5)
|
|
39
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
67
|
rspec-support (~> 3.13.0)
|
|
41
|
-
rspec-mocks (3.13.
|
|
68
|
+
rspec-mocks (3.13.6)
|
|
42
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
43
70
|
rspec-support (~> 3.13.0)
|
|
44
|
-
rspec-support (3.13.
|
|
71
|
+
rspec-support (3.13.6)
|
|
45
72
|
simplecov (0.22.0)
|
|
46
73
|
docile (~> 1.1)
|
|
47
74
|
simplecov-html (~> 0.11)
|
|
48
75
|
simplecov_json_formatter (~> 0.1)
|
|
49
|
-
simplecov-html (0.13.
|
|
76
|
+
simplecov-html (0.13.2)
|
|
50
77
|
simplecov_json_formatter (0.1.4)
|
|
78
|
+
warning (1.5.0)
|
|
79
|
+
yard (0.9.37)
|
|
80
|
+
yard-lint (1.2.3)
|
|
81
|
+
yard (~> 0.9)
|
|
82
|
+
zeitwerk (~> 2.6)
|
|
83
|
+
zeitwerk (2.7.3)
|
|
51
84
|
|
|
52
85
|
PLATFORMS
|
|
53
86
|
aarch64-linux-gnu
|
|
@@ -67,6 +100,8 @@ DEPENDENCIES
|
|
|
67
100
|
karafka-core!
|
|
68
101
|
rspec
|
|
69
102
|
simplecov
|
|
103
|
+
warning
|
|
104
|
+
yard-lint
|
|
70
105
|
|
|
71
106
|
BUNDLED WITH
|
|
72
107
|
2.6.9
|
data/karafka-core.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ require 'karafka/core/version'
|
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |spec|
|
|
9
9
|
spec.name = 'karafka-core'
|
|
10
|
-
spec.version =
|
|
10
|
+
spec.version = Karafka::Core::VERSION
|
|
11
11
|
spec.platform = Gem::Platform::RUBY
|
|
12
12
|
spec.authors = ['Maciej Mensfeld']
|
|
13
13
|
spec.email = %w[contact@karafka.io]
|
|
@@ -16,16 +16,15 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.description = 'A toolset of small support modules used throughout the Karafka ecosystem'
|
|
17
17
|
spec.licenses = %w[MIT]
|
|
18
18
|
|
|
19
|
-
spec.add_dependency 'karafka-rdkafka', '>= 0.
|
|
19
|
+
spec.add_dependency 'karafka-rdkafka', '>= 0.20.0'
|
|
20
20
|
spec.add_dependency 'logger', '>= 1.6.0'
|
|
21
21
|
|
|
22
|
-
spec.required_ruby_version = '>= 3.
|
|
22
|
+
spec.required_ruby_version = '>= 3.2.0'
|
|
23
23
|
|
|
24
24
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
|
25
25
|
spec.require_paths = %w[lib]
|
|
26
26
|
|
|
27
27
|
spec.metadata = {
|
|
28
|
-
'funding_uri' => 'https://karafka.io/#become-pro',
|
|
29
28
|
'homepage_uri' => 'https://karafka.io',
|
|
30
29
|
'changelog_uri' => 'https://karafka.io/docs/Changelog-Karafka-Core',
|
|
31
30
|
'bug_tracker_uri' => 'https://github.com/karafka/karafka-core/issues',
|
|
@@ -22,6 +22,8 @@ module Karafka
|
|
|
22
22
|
@children = []
|
|
23
23
|
@nestings = nestings
|
|
24
24
|
@compiled = false
|
|
25
|
+
@configs_refs = {}
|
|
26
|
+
@local_defs = []
|
|
25
27
|
instance_eval(&nestings)
|
|
26
28
|
end
|
|
27
29
|
|
|
@@ -58,7 +60,14 @@ module Karafka
|
|
|
58
60
|
|
|
59
61
|
@children.each do |value|
|
|
60
62
|
config[value.node_name] = if value.is_a?(Leaf)
|
|
61
|
-
result =
|
|
63
|
+
result = if @configs_refs.key?(value.node_name)
|
|
64
|
+
@configs_refs[value.node_name]
|
|
65
|
+
elsif value.constructor
|
|
66
|
+
value.constructor.call
|
|
67
|
+
elsif value.default
|
|
68
|
+
value.default
|
|
69
|
+
end
|
|
70
|
+
|
|
62
71
|
# We need to check if value is not a result node for cases
|
|
63
72
|
# where we merge additional config
|
|
64
73
|
result.is_a?(Node) ? result.to_h : result
|
|
@@ -76,15 +85,16 @@ module Karafka
|
|
|
76
85
|
def deep_dup
|
|
77
86
|
dupped = Node.new(node_name, nestings)
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
if value.is_a?(Leaf)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
children.each do |value|
|
|
89
|
+
dupped.children << if value.is_a?(Leaf)
|
|
90
|
+
# After inheritance we need to reload the state so the leafs are
|
|
91
|
+
# recompiled again
|
|
92
|
+
value = value.dup
|
|
93
|
+
value.compiled = false
|
|
94
|
+
value
|
|
95
|
+
else
|
|
96
|
+
value.deep_dup
|
|
97
|
+
end
|
|
88
98
|
end
|
|
89
99
|
|
|
90
100
|
dupped
|
|
@@ -96,12 +106,12 @@ module Karafka
|
|
|
96
106
|
@children.each do |value|
|
|
97
107
|
# Do not redefine something that was already set during compilation
|
|
98
108
|
# This will allow us to reconfigure things and skip override with defaults
|
|
99
|
-
skippable =
|
|
109
|
+
skippable = @configs_refs.key?(value.node_name) || (value.is_a?(Leaf) && value.compiled?)
|
|
100
110
|
lazy_leaf = value.is_a?(Leaf) && value.lazy?
|
|
101
111
|
|
|
102
112
|
# Do not create accessor for leafs that are lazy as they will get a custom method
|
|
103
113
|
# created instead
|
|
104
|
-
|
|
114
|
+
build_accessors(value) unless lazy_leaf
|
|
105
115
|
|
|
106
116
|
next if skippable
|
|
107
117
|
|
|
@@ -123,7 +133,7 @@ module Karafka
|
|
|
123
133
|
if lazy_leaf && !initialized
|
|
124
134
|
build_dynamic_accessor(value)
|
|
125
135
|
else
|
|
126
|
-
|
|
136
|
+
@configs_refs[value.node_name] = initialized
|
|
127
137
|
end
|
|
128
138
|
end
|
|
129
139
|
|
|
@@ -139,16 +149,18 @@ module Karafka
|
|
|
139
149
|
#
|
|
140
150
|
# @param value [Leaf]
|
|
141
151
|
def build_dynamic_accessor(value)
|
|
142
|
-
singleton_class.attr_writer(value.node_name)
|
|
143
|
-
|
|
144
152
|
define_singleton_method(value.node_name) do
|
|
145
|
-
existing =
|
|
153
|
+
existing = @configs_refs.fetch(value.node_name, false)
|
|
146
154
|
|
|
147
|
-
return existing
|
|
155
|
+
return existing unless existing == false
|
|
148
156
|
|
|
149
157
|
built = call_constructor(value)
|
|
150
158
|
|
|
151
|
-
|
|
159
|
+
@configs_refs[value.node_name] = built
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
define_singleton_method(:"#{value.node_name}=") do |new_value|
|
|
163
|
+
@configs_refs[value.node_name] = new_value
|
|
152
164
|
end
|
|
153
165
|
end
|
|
154
166
|
|
|
@@ -165,6 +177,32 @@ module Karafka
|
|
|
165
177
|
constructor.call(value.default)
|
|
166
178
|
end
|
|
167
179
|
end
|
|
180
|
+
|
|
181
|
+
# Builds regular accessors for value fetching
|
|
182
|
+
#
|
|
183
|
+
# @param value [Leaf]
|
|
184
|
+
def build_accessors(value)
|
|
185
|
+
reader_name = value.node_name.to_sym
|
|
186
|
+
reader_respond = respond_to?(reader_name)
|
|
187
|
+
# There is a weird edge-case from 2020, where nodes would not redefine methods that
|
|
188
|
+
# would be defined on Object. Some of users were defining things like `#logger` on
|
|
189
|
+
# object and then we would not redefine it for nodes. This ensures that we only do not
|
|
190
|
+
# redefine our own definitions but we do redefine any user "accidentally" inherited
|
|
191
|
+
# methods
|
|
192
|
+
if reader_respond ? !@local_defs.include?(reader_name) : true
|
|
193
|
+
@local_defs << reader_name
|
|
194
|
+
|
|
195
|
+
define_singleton_method(reader_name) do
|
|
196
|
+
@configs_refs[reader_name]
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
return if respond_to?(:"#{value.node_name}=")
|
|
201
|
+
|
|
202
|
+
define_singleton_method(:"#{value.node_name}=") do |new_value|
|
|
203
|
+
@configs_refs[value.node_name] = new_value
|
|
204
|
+
end
|
|
205
|
+
end
|
|
168
206
|
end
|
|
169
207
|
end
|
|
170
208
|
end
|
|
@@ -37,9 +37,8 @@ module Karafka
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# Allows for a per instance configuration (if needed)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
config.configure(&block)
|
|
40
|
+
def configure(&)
|
|
41
|
+
config.configure(&)
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
44
|
|
|
@@ -58,28 +57,13 @@ module Karafka
|
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
# Allows for a per class configuration (if needed)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
config.configure(&block)
|
|
60
|
+
def configure(&)
|
|
61
|
+
config.configure(&)
|
|
64
62
|
end
|
|
65
63
|
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
# Pipes the settings setup to the config root node
|
|
70
|
-
def setting(...)
|
|
71
|
-
config.setting(...)
|
|
72
|
-
end
|
|
73
|
-
CODE
|
|
74
|
-
else
|
|
75
|
-
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
|
76
|
-
# Pipes the settings setup to the config root node
|
|
77
|
-
# @param args [Object] anything provided to settings
|
|
78
|
-
# @param block [Proc] block for settings
|
|
79
|
-
def setting(*args, &block)
|
|
80
|
-
config.setting(*args, &block)
|
|
81
|
-
end
|
|
82
|
-
CODE
|
|
64
|
+
# Pipes the settings setup to the config root node
|
|
65
|
+
def setting(...)
|
|
66
|
+
config.setting(...)
|
|
83
67
|
end
|
|
84
68
|
end
|
|
85
69
|
end
|
|
@@ -27,16 +27,15 @@ module Karafka
|
|
|
27
27
|
# Allows for definition of a scope/namespace for nested validations
|
|
28
28
|
#
|
|
29
29
|
# @param path [Symbol] path in the hash for nesting
|
|
30
|
-
# @param block [Proc] nested rule code or more nestings inside
|
|
31
30
|
#
|
|
32
31
|
# @example
|
|
33
32
|
# nested(:key) do
|
|
34
33
|
# required(:inside) { |inside| inside.is_a?(String) }
|
|
35
34
|
# end
|
|
36
|
-
def nested(path, &
|
|
35
|
+
def nested(path, &)
|
|
37
36
|
init_accu
|
|
38
37
|
@nested << path
|
|
39
|
-
instance_eval(&
|
|
38
|
+
instance_eval(&)
|
|
40
39
|
@nested.pop
|
|
41
40
|
end
|
|
42
41
|
|
|
@@ -169,10 +168,8 @@ module Karafka
|
|
|
169
168
|
|
|
170
169
|
return if result == true
|
|
171
170
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
sub_result[0] = scope + sub_result[0]
|
|
175
|
-
end
|
|
171
|
+
result&.each do |sub_result|
|
|
172
|
+
sub_result[0] = scope + sub_result[0]
|
|
176
173
|
end
|
|
177
174
|
|
|
178
175
|
errors.push(*result)
|
|
@@ -7,6 +7,11 @@ module Karafka
|
|
|
7
7
|
class Result
|
|
8
8
|
attr_reader :errors
|
|
9
9
|
|
|
10
|
+
# Empty hash that we use when no errors to save on allocations
|
|
11
|
+
EMPTY_HASH = {}.freeze
|
|
12
|
+
|
|
13
|
+
private_constant :EMPTY_HASH
|
|
14
|
+
|
|
10
15
|
# Builds a result object and remaps (if needed) error keys to proper error messages
|
|
11
16
|
#
|
|
12
17
|
# @param errors [Array<Array>] array with sub-arrays with paths and error keys
|
|
@@ -14,7 +19,7 @@ module Karafka
|
|
|
14
19
|
def initialize(errors, contract)
|
|
15
20
|
# Short track to skip object allocation for the happy path
|
|
16
21
|
if errors.empty?
|
|
17
|
-
@errors =
|
|
22
|
+
@errors = EMPTY_HASH
|
|
18
23
|
return
|
|
19
24
|
end
|
|
20
25
|
|
|
@@ -13,7 +13,7 @@ module Karafka
|
|
|
13
13
|
# RSpec.extend SupportEngine::RSpecLocator.new(__FILE__)
|
|
14
14
|
class RSpecLocator < Module
|
|
15
15
|
# @param spec_helper_file_path [String] path to the spec_helper.rb file
|
|
16
|
-
# @param inflections [Hash
|
|
16
|
+
# @param inflections [Hash{String => String}] optional inflections map
|
|
17
17
|
def initialize(spec_helper_file_path, inflections = {})
|
|
18
18
|
super()
|
|
19
19
|
@inflections = inflections
|
|
@@ -27,19 +27,15 @@ module Karafka
|
|
|
27
27
|
#
|
|
28
28
|
# @param event_id [String, Symbol] event id
|
|
29
29
|
# @param payload [Hash]
|
|
30
|
-
|
|
31
|
-
def instrument(event_id, payload = EMPTY_HASH, &block)
|
|
30
|
+
def instrument(event_id, payload = EMPTY_HASH, &)
|
|
32
31
|
full_event_name = @mapped_events[event_id] ||= [event_id, @namespace].compact.join('.')
|
|
33
32
|
|
|
34
|
-
@notifications_bus.instrument(full_event_name, payload, &
|
|
33
|
+
@notifications_bus.instrument(full_event_name, payload, &)
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
# Allows us to subscribe to the notification bus
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# @param block [Proc] optional block for subscription
|
|
41
|
-
def subscribe(*args, &block)
|
|
42
|
-
@notifications_bus.subscribe(*args, &block)
|
|
37
|
+
def subscribe(*, &)
|
|
38
|
+
@notifications_bus.subscribe(*, &)
|
|
43
39
|
end
|
|
44
40
|
|
|
45
41
|
# Allows for removal of whatever was subscribed
|
|
@@ -50,14 +46,14 @@ module Karafka
|
|
|
50
46
|
@notifications_bus.unsubscribe(listener_or_block)
|
|
51
47
|
end
|
|
52
48
|
|
|
53
|
-
# @return [Hash
|
|
49
|
+
# @return [Hash{String => Array}] hash where keys are events and values are arrays with
|
|
54
50
|
# listeners subscribed to particular events. Since different events may have different
|
|
55
51
|
# listeners, this is returned that way.
|
|
56
52
|
#
|
|
57
|
-
# @note Please do not modify this hash. It should be used only for debugging.
|
|
58
|
-
#
|
|
59
53
|
# @example If you need to get only classes of listeners, you can run following code:
|
|
60
54
|
# monitor.listeners.map(&:class)
|
|
55
|
+
#
|
|
56
|
+
# @note Please do not modify this hash. It should be used only for debugging.
|
|
61
57
|
def listeners
|
|
62
58
|
@notifications_bus.listeners
|
|
63
59
|
end
|
|
@@ -107,7 +107,7 @@ module Karafka
|
|
|
107
107
|
# Allows for code instrumentation
|
|
108
108
|
# Runs the provided code and sends the instrumentation details to all registered listeners
|
|
109
109
|
#
|
|
110
|
-
# @param event_id [String]
|
|
110
|
+
# @param event_id [String]
|
|
111
111
|
# @param payload [Hash] payload for the instrumentation
|
|
112
112
|
# @yield [Proc] instrumented code
|
|
113
113
|
# @return [Object] whatever the provided block (if any) returns
|
|
@@ -139,11 +139,31 @@ module Karafka
|
|
|
139
139
|
return
|
|
140
140
|
end
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
time ? payload.merge(time: time) : payload
|
|
145
|
-
)
|
|
142
|
+
final_payload = build_payload(payload, time)
|
|
143
|
+
event = Event.new(event_id, final_payload)
|
|
146
144
|
|
|
145
|
+
notify_listeners(event_id, event, assigned_listeners)
|
|
146
|
+
|
|
147
|
+
result
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
private
|
|
151
|
+
|
|
152
|
+
# Builds the final payload with time information if available
|
|
153
|
+
# @param payload [Hash] original payload
|
|
154
|
+
# @param time [Float, nil] execution time if block was given
|
|
155
|
+
# @return [Hash] final payload
|
|
156
|
+
def build_payload(payload, time)
|
|
157
|
+
return payload unless time
|
|
158
|
+
|
|
159
|
+
payload.empty? ? { time: time } : payload.merge(time: time)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Notifies all assigned listeners about the event
|
|
163
|
+
# @param event_id [String]
|
|
164
|
+
# @param event [Event] event object
|
|
165
|
+
# @param assigned_listeners [Array] list of listeners to notify
|
|
166
|
+
def notify_listeners(event_id, event, assigned_listeners)
|
|
147
167
|
assigned_listeners.each do |listener|
|
|
148
168
|
if listener.is_a?(Proc)
|
|
149
169
|
listener.call(event)
|
|
@@ -151,8 +171,6 @@ module Karafka
|
|
|
151
171
|
listener.send(@events_methods_map[event_id], event)
|
|
152
172
|
end
|
|
153
173
|
end
|
|
154
|
-
|
|
155
|
-
result
|
|
156
174
|
end
|
|
157
175
|
end
|
|
158
176
|
end
|
|
@@ -28,6 +28,8 @@ module Karafka
|
|
|
28
28
|
# Operate on ms precision only
|
|
29
29
|
@previous_at = monotonic_now.round
|
|
30
30
|
@current_at = @previous_at
|
|
31
|
+
# Cache for memoized suffix keys to avoid repeated string allocations
|
|
32
|
+
@suffix_keys_cache = {}
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
# @param emited_stats [Hash] original emited statistics
|
|
@@ -62,16 +64,15 @@ module Karafka
|
|
|
62
64
|
def diff(previous, current)
|
|
63
65
|
if current.is_a?(Hash)
|
|
64
66
|
filled_previous = previous || EMPTY_HASH
|
|
65
|
-
filled_current = current || EMPTY_HASH
|
|
66
67
|
|
|
67
68
|
# @note We cannot use #each_key as we modify the content of the current scope
|
|
68
69
|
# in place (in case it's a hash)
|
|
69
70
|
current.keys.each do |key|
|
|
70
71
|
append(
|
|
71
72
|
filled_previous,
|
|
72
|
-
|
|
73
|
+
current,
|
|
73
74
|
key,
|
|
74
|
-
diff(filled_previous[key],
|
|
75
|
+
diff(filled_previous[key], current[key])
|
|
75
76
|
)
|
|
76
77
|
end
|
|
77
78
|
end
|
|
@@ -96,7 +97,7 @@ module Karafka
|
|
|
96
97
|
return unless result.is_a?(Numeric)
|
|
97
98
|
return if current.frozen?
|
|
98
99
|
|
|
99
|
-
freeze_duration_key =
|
|
100
|
+
freeze_duration_key, delta_key = suffix_keys_for(key)
|
|
100
101
|
|
|
101
102
|
if result.zero?
|
|
102
103
|
current[freeze_duration_key] = previous[freeze_duration_key] || 0
|
|
@@ -105,7 +106,18 @@ module Karafka
|
|
|
105
106
|
current[freeze_duration_key] = 0
|
|
106
107
|
end
|
|
107
108
|
|
|
108
|
-
current[
|
|
109
|
+
current[delta_key] = result
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Returns memoized suffix keys for a given key to avoid repeated string allocations
|
|
113
|
+
#
|
|
114
|
+
# @param key [Object] the original key
|
|
115
|
+
# @return [Array<String>] frozen freeze_duration_key and delta_key
|
|
116
|
+
def suffix_keys_for(key)
|
|
117
|
+
@suffix_keys_cache[key] ||= [
|
|
118
|
+
"#{key}_fd".freeze,
|
|
119
|
+
"#{key}_d".freeze
|
|
120
|
+
].freeze
|
|
109
121
|
end
|
|
110
122
|
end
|
|
111
123
|
end
|
data/lib/karafka/core/version.rb
CHANGED
data/lib/karafka-core.rb
CHANGED
|
@@ -1,47 +1,37 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
karafka/core/contractable/rule
|
|
26
|
-
|
|
27
|
-
karafka/core/instrumentation
|
|
28
|
-
karafka/core/instrumentation/callbacks_manager
|
|
29
|
-
|
|
30
|
-
karafka/core/taggable
|
|
31
|
-
karafka/core/taggable/tags
|
|
32
|
-
|
|
33
|
-
karafka/core/patches/rdkafka/bindings
|
|
34
|
-
].each { |dependency| require dependency }
|
|
3
|
+
require 'logger'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
require 'rdkafka'
|
|
6
|
+
require 'karafka/core'
|
|
7
|
+
require 'karafka/core/version'
|
|
8
|
+
require 'karafka/core/helpers/time'
|
|
9
|
+
require 'karafka/core/monitoring'
|
|
10
|
+
require 'karafka/core/monitoring/event'
|
|
11
|
+
require 'karafka/core/monitoring/monitor'
|
|
12
|
+
require 'karafka/core/monitoring/notifications'
|
|
13
|
+
require 'karafka/core/monitoring/statistics_decorator'
|
|
14
|
+
require 'karafka/core/configurable'
|
|
15
|
+
require 'karafka/core/configurable/leaf'
|
|
16
|
+
require 'karafka/core/configurable/node'
|
|
17
|
+
require 'karafka/core/contractable/contract'
|
|
18
|
+
require 'karafka/core/contractable/result'
|
|
19
|
+
require 'karafka/core/contractable/rule'
|
|
20
|
+
require 'karafka/core/instrumentation'
|
|
21
|
+
require 'karafka/core/instrumentation/callbacks_manager'
|
|
22
|
+
require 'karafka/core/taggable'
|
|
23
|
+
require 'karafka/core/taggable/tags'
|
|
24
|
+
require 'karafka/core/patches/rdkafka/bindings'
|
|
35
25
|
|
|
36
26
|
# Karafka framework main namespace
|
|
37
27
|
module Karafka
|
|
38
28
|
end
|
|
39
29
|
|
|
40
30
|
# Patch rdkafka
|
|
41
|
-
|
|
31
|
+
Rdkafka::Bindings.include(Karafka::Core::Patches::Rdkafka::Bindings)
|
|
42
32
|
|
|
43
|
-
instrumentation =
|
|
44
|
-
rd_config =
|
|
33
|
+
instrumentation = Karafka::Core::Instrumentation
|
|
34
|
+
rd_config = Rdkafka::Config
|
|
45
35
|
|
|
46
36
|
# Rdkafka uses a single global callback for things. We bypass that by injecting a manager for
|
|
47
37
|
# each callback type. Callback manager allows us to register more than one callback
|
|
@@ -53,4 +43,4 @@ rd_config.oauthbearer_token_refresh_callback = instrumentation.oauthbearer_token
|
|
|
53
43
|
# This loads librdkafka components into memory prior to initializing the client.
|
|
54
44
|
# This mitigates macos forking issues.
|
|
55
45
|
# @see https://github.com/confluentinc/librdkafka/issues/4590
|
|
56
|
-
|
|
46
|
+
Rdkafka::Bindings.rd_kafka_global_init if Rdkafka::Bindings.respond_to?(:rd_kafka_global_init)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: karafka-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.5.
|
|
4
|
+
version: 2.5.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maciej Mensfeld
|
|
@@ -15,20 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
19
|
-
- - "<"
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.21.0
|
|
18
|
+
version: 0.20.0
|
|
22
19
|
type: :runtime
|
|
23
20
|
prerelease: false
|
|
24
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
22
|
requirements:
|
|
26
23
|
- - ">="
|
|
27
24
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 0.
|
|
29
|
-
- - "<"
|
|
30
|
-
- !ruby/object:Gem::Version
|
|
31
|
-
version: 0.21.0
|
|
25
|
+
version: 0.20.0
|
|
32
26
|
- !ruby/object:Gem::Dependency
|
|
33
27
|
name: logger
|
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,18 +46,19 @@ extra_rdoc_files: []
|
|
|
52
46
|
files:
|
|
53
47
|
- ".coditsu/ci.yml"
|
|
54
48
|
- ".console_irbrc"
|
|
55
|
-
- ".diffend.yml"
|
|
56
49
|
- ".github/CODEOWNERS"
|
|
57
50
|
- ".github/FUNDING.yml"
|
|
58
51
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
59
52
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
60
53
|
- ".github/workflows/ci.yml"
|
|
61
54
|
- ".github/workflows/push.yml"
|
|
55
|
+
- ".github/workflows/trigger-wiki-refresh.yml"
|
|
62
56
|
- ".github/workflows/verify-action-pins.yml"
|
|
63
57
|
- ".gitignore"
|
|
64
58
|
- ".rspec"
|
|
65
59
|
- ".ruby-gemset"
|
|
66
60
|
- ".ruby-version"
|
|
61
|
+
- ".yard-lint.yml"
|
|
67
62
|
- CHANGELOG.md
|
|
68
63
|
- CODE_OF_CONDUCT.md
|
|
69
64
|
- Gemfile
|
|
@@ -101,7 +96,6 @@ homepage: https://karafka.io
|
|
|
101
96
|
licenses:
|
|
102
97
|
- MIT
|
|
103
98
|
metadata:
|
|
104
|
-
funding_uri: https://karafka.io/#become-pro
|
|
105
99
|
homepage_uri: https://karafka.io
|
|
106
100
|
changelog_uri: https://karafka.io/docs/Changelog-Karafka-Core
|
|
107
101
|
bug_tracker_uri: https://github.com/karafka/karafka-core/issues
|
|
@@ -115,14 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
115
109
|
requirements:
|
|
116
110
|
- - ">="
|
|
117
111
|
- !ruby/object:Gem::Version
|
|
118
|
-
version: 3.
|
|
112
|
+
version: 3.2.0
|
|
119
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
114
|
requirements:
|
|
121
115
|
- - ">="
|
|
122
116
|
- !ruby/object:Gem::Version
|
|
123
117
|
version: '0'
|
|
124
118
|
requirements: []
|
|
125
|
-
rubygems_version: 3.6.
|
|
119
|
+
rubygems_version: 3.6.9
|
|
126
120
|
specification_version: 4
|
|
127
121
|
summary: Karafka ecosystem core modules
|
|
128
122
|
test_files: []
|
data/.diffend.yml
DELETED