karafka-core 2.5.7 → 2.5.9
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 +44 -39
- data/.github/workflows/push.yml +3 -3
- data/.github/workflows/trigger-wiki-refresh.yml +1 -1
- data/.github/workflows/verify-action-pins.yml +1 -1
- data/.gitignore +0 -1
- data/.rubocop.yml +37 -0
- data/.ruby-version +1 -1
- data/.yard-lint.yml +275 -0
- data/CHANGELOG.md +12 -4
- data/Gemfile +5 -7
- data/Gemfile.lint +13 -0
- data/Gemfile.lint.lock +103 -0
- data/Gemfile.lock +19 -24
- data/Rakefile +14 -2
- data/karafka-core.gemspec +21 -21
- data/lib/karafka/core/configurable/node.rb +39 -39
- data/lib/karafka/core/configurable.rb +8 -10
- data/lib/karafka/core/contractable/contract.rb +6 -9
- data/lib/karafka/core/contractable/result.rb +10 -10
- data/lib/karafka/core/helpers/rspec_locator.rb +10 -10
- data/lib/karafka/core/helpers/time.rb +1 -1
- data/lib/karafka/core/monitoring/event.rb +1 -1
- data/lib/karafka/core/monitoring/monitor.rb +8 -12
- data/lib/karafka/core/monitoring/notifications.rb +25 -14
- data/lib/karafka/core/monitoring/statistics_decorator.rb +71 -54
- data/lib/karafka/core/version.rb +1 -1
- data/lib/karafka/core.rb +1 -1
- data/lib/karafka-core.rb +26 -26
- data/package-lock.json +331 -0
- data/package.json +9 -0
- data/renovate.json +28 -6
- data/test/lib/karafka/core/configurable/leaf_test.rb +3 -0
- data/test/lib/karafka/core/configurable/node_test.rb +3 -0
- data/test/lib/karafka/core/configurable_test.rb +504 -0
- data/test/lib/karafka/core/contractable/contract_test.rb +241 -0
- data/test/lib/karafka/core/contractable/result_test.rb +106 -0
- data/test/lib/karafka/core/contractable/rule_test.rb +5 -0
- data/test/lib/karafka/core/contractable_test.rb +3 -0
- data/test/lib/karafka/core/helpers/time_test.rb +29 -0
- data/test/lib/karafka/core/instrumentation/callbacks_manager_test.rb +81 -0
- data/test/lib/karafka/core/instrumentation_test.rb +35 -0
- data/test/lib/karafka/core/monitoring/event_test.rb +25 -0
- data/test/lib/karafka/core/monitoring/monitor_test.rb +237 -0
- data/test/lib/karafka/core/monitoring/notifications_test.rb +275 -0
- data/test/lib/karafka/core/monitoring/statistics_decorator_test.rb +284 -0
- data/test/lib/karafka/core/monitoring_test.rb +3 -0
- data/test/lib/karafka/core/patches/rdkafka/bindings_test.rb +25 -0
- data/test/lib/karafka/core/taggable/tags_test.rb +66 -0
- data/test/lib/karafka/core/taggable_test.rb +36 -0
- data/test/lib/karafka/core/version_test.rb +5 -0
- data/test/lib/karafka/core_test.rb +13 -0
- data/test/lib/karafka-core_test.rb +3 -0
- data/test/support/class_builder.rb +24 -0
- data/test/support/describe_current_helper.rb +85 -0
- data/test/test_helper.rb +55 -0
- metadata +32 -5
- data/.coditsu/ci.yml +0 -3
- data/.diffend.yml +0 -3
- data/.rspec +0 -1
data/Gemfile.lint.lock
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: https://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
ast (2.4.3)
|
|
5
|
+
json (2.18.0)
|
|
6
|
+
language_server-protocol (3.17.0.5)
|
|
7
|
+
lint_roller (1.1.0)
|
|
8
|
+
parallel (1.27.0)
|
|
9
|
+
parser (3.3.10.1)
|
|
10
|
+
ast (~> 2.4.1)
|
|
11
|
+
racc
|
|
12
|
+
prism (1.8.0)
|
|
13
|
+
racc (1.8.1)
|
|
14
|
+
rainbow (3.1.1)
|
|
15
|
+
regexp_parser (2.11.3)
|
|
16
|
+
rubocop (1.82.1)
|
|
17
|
+
json (~> 2.3)
|
|
18
|
+
language_server-protocol (~> 3.17.0.2)
|
|
19
|
+
lint_roller (~> 1.1.0)
|
|
20
|
+
parallel (~> 1.10)
|
|
21
|
+
parser (>= 3.3.0.2)
|
|
22
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
23
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
24
|
+
rubocop-ast (>= 1.48.0, < 2.0)
|
|
25
|
+
ruby-progressbar (~> 1.7)
|
|
26
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
27
|
+
rubocop-ast (1.49.0)
|
|
28
|
+
parser (>= 3.3.7.2)
|
|
29
|
+
prism (~> 1.7)
|
|
30
|
+
rubocop-minitest (0.39.1)
|
|
31
|
+
lint_roller (~> 1.1)
|
|
32
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
33
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
34
|
+
rubocop-performance (1.26.1)
|
|
35
|
+
lint_roller (~> 1.1)
|
|
36
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
37
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
38
|
+
rubocop-thread_safety (0.7.3)
|
|
39
|
+
lint_roller (~> 1.1)
|
|
40
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
41
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
42
|
+
ruby-progressbar (1.13.0)
|
|
43
|
+
standard (1.53.0)
|
|
44
|
+
language_server-protocol (~> 3.17.0.2)
|
|
45
|
+
lint_roller (~> 1.0)
|
|
46
|
+
rubocop (~> 1.82.0)
|
|
47
|
+
standard-custom (~> 1.0.0)
|
|
48
|
+
standard-performance (~> 1.8)
|
|
49
|
+
standard-custom (1.0.2)
|
|
50
|
+
lint_roller (~> 1.0)
|
|
51
|
+
rubocop (~> 1.50)
|
|
52
|
+
standard-performance (1.9.0)
|
|
53
|
+
lint_roller (~> 1.1)
|
|
54
|
+
rubocop-performance (~> 1.26.0)
|
|
55
|
+
unicode-display_width (3.2.0)
|
|
56
|
+
unicode-emoji (~> 4.1)
|
|
57
|
+
unicode-emoji (4.2.0)
|
|
58
|
+
yard (0.9.38)
|
|
59
|
+
yard-lint (1.4.0)
|
|
60
|
+
yard (~> 0.9)
|
|
61
|
+
zeitwerk (~> 2.6)
|
|
62
|
+
zeitwerk (2.7.4)
|
|
63
|
+
|
|
64
|
+
PLATFORMS
|
|
65
|
+
ruby
|
|
66
|
+
x86_64-linux
|
|
67
|
+
|
|
68
|
+
DEPENDENCIES
|
|
69
|
+
rubocop-minitest
|
|
70
|
+
rubocop-performance
|
|
71
|
+
rubocop-thread_safety
|
|
72
|
+
standard
|
|
73
|
+
standard-performance
|
|
74
|
+
yard-lint
|
|
75
|
+
|
|
76
|
+
CHECKSUMS
|
|
77
|
+
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
78
|
+
json (2.18.0) sha256=b10506aee4183f5cf49e0efc48073d7b75843ce3782c68dbeb763351c08fd505
|
|
79
|
+
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
|
80
|
+
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
81
|
+
parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
|
|
82
|
+
parser (3.3.10.1) sha256=06f6a725d2cd91e5e7f2b7c32ba143631e1f7c8ae2fb918fc4cebec187e6a688
|
|
83
|
+
prism (1.8.0) sha256=84453a16ef5530ea62c5f03ec16b52a459575ad4e7b9c2b360fd8ce2c39c1254
|
|
84
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
85
|
+
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
86
|
+
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
|
87
|
+
rubocop (1.82.1) sha256=09f1a6a654a960eda767aebea33e47603080f8e9c9a3f019bf9b94c9cab5e273
|
|
88
|
+
rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
|
|
89
|
+
rubocop-minitest (0.39.1) sha256=998398d6da4026d297f0f9bf709a1eac5f2b6947c24431f94af08138510cf7ed
|
|
90
|
+
rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
|
|
91
|
+
rubocop-thread_safety (0.7.3) sha256=067cdd52fbf5deffc18995437e45b5194236eaff4f71de3375a1f6052e48f431
|
|
92
|
+
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
93
|
+
standard (1.53.0) sha256=f3c9493385db7079d0abce6f7582f553122156997b81258cd361d3480eeacf9c
|
|
94
|
+
standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
|
|
95
|
+
standard-performance (1.9.0) sha256=49483d31be448292951d80e5e67cdcb576c2502103c7b40aec6f1b6e9c88e3f2
|
|
96
|
+
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
97
|
+
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
98
|
+
yard (0.9.38) sha256=721fb82afb10532aa49860655f6cc2eaa7130889df291b052e1e6b268283010f
|
|
99
|
+
yard-lint (1.4.0) sha256=7dd88fbb08fd77cb840bea899d58812817b36d92291b5693dd0eeb3af9f91f0f
|
|
100
|
+
zeitwerk (2.7.4) sha256=2bef90f356bdafe9a6c2bd32bcd804f83a4f9b8bc27f3600fff051eb3edcec8b
|
|
101
|
+
|
|
102
|
+
BUNDLED WITH
|
|
103
|
+
4.0.3
|
data/Gemfile.lock
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
karafka-core (2.5.
|
|
4
|
+
karafka-core (2.5.9)
|
|
5
5
|
karafka-rdkafka (>= 0.20.0)
|
|
6
6
|
logger (>= 1.6.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
byebug (
|
|
12
|
-
|
|
11
|
+
byebug (13.0.0)
|
|
12
|
+
reline (>= 0.6.0)
|
|
13
13
|
docile (1.4.1)
|
|
14
|
+
drb (2.2.3)
|
|
14
15
|
ffi (1.17.2)
|
|
15
16
|
ffi (1.17.2-aarch64-linux-gnu)
|
|
16
17
|
ffi (1.17.2-aarch64-linux-musl)
|
|
@@ -22,32 +23,33 @@ GEM
|
|
|
22
23
|
ffi (1.17.2-x86_64-darwin)
|
|
23
24
|
ffi (1.17.2-x86_64-linux-gnu)
|
|
24
25
|
ffi (1.17.2-x86_64-linux-musl)
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
io-console (0.8.2)
|
|
27
|
+
json (2.15.1)
|
|
28
|
+
karafka-rdkafka (0.22.2)
|
|
27
29
|
ffi (~> 1.15)
|
|
28
30
|
json (> 2.0)
|
|
29
31
|
logger
|
|
30
32
|
mini_portile2 (~> 2.6)
|
|
31
33
|
rake (> 12)
|
|
32
|
-
karafka-rdkafka (0.
|
|
34
|
+
karafka-rdkafka (0.22.2-aarch64-linux-gnu)
|
|
33
35
|
ffi (~> 1.15)
|
|
34
36
|
json (> 2.0)
|
|
35
37
|
logger
|
|
36
38
|
mini_portile2 (~> 2.6)
|
|
37
39
|
rake (> 12)
|
|
38
|
-
karafka-rdkafka (0.
|
|
40
|
+
karafka-rdkafka (0.22.2-arm64-darwin)
|
|
39
41
|
ffi (~> 1.15)
|
|
40
42
|
json (> 2.0)
|
|
41
43
|
logger
|
|
42
44
|
mini_portile2 (~> 2.6)
|
|
43
45
|
rake (> 12)
|
|
44
|
-
karafka-rdkafka (0.
|
|
46
|
+
karafka-rdkafka (0.22.2-x86_64-linux-gnu)
|
|
45
47
|
ffi (~> 1.15)
|
|
46
48
|
json (> 2.0)
|
|
47
49
|
logger
|
|
48
50
|
mini_portile2 (~> 2.6)
|
|
49
51
|
rake (> 12)
|
|
50
|
-
karafka-rdkafka (0.
|
|
52
|
+
karafka-rdkafka (0.22.2-x86_64-linux-musl)
|
|
51
53
|
ffi (~> 1.15)
|
|
52
54
|
json (> 2.0)
|
|
53
55
|
logger
|
|
@@ -55,25 +57,18 @@ GEM
|
|
|
55
57
|
rake (> 12)
|
|
56
58
|
logger (1.7.0)
|
|
57
59
|
mini_portile2 (2.8.9)
|
|
60
|
+
minitest (6.0.2)
|
|
61
|
+
drb (~> 2.0)
|
|
62
|
+
prism (~> 1.5)
|
|
63
|
+
prism (1.9.0)
|
|
58
64
|
rake (13.3.0)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
rspec-expectations (~> 3.13.0)
|
|
62
|
-
rspec-mocks (~> 3.13.0)
|
|
63
|
-
rspec-core (3.13.4)
|
|
64
|
-
rspec-support (~> 3.13.0)
|
|
65
|
-
rspec-expectations (3.13.5)
|
|
66
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
67
|
-
rspec-support (~> 3.13.0)
|
|
68
|
-
rspec-mocks (3.13.5)
|
|
69
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
70
|
-
rspec-support (~> 3.13.0)
|
|
71
|
-
rspec-support (3.13.4)
|
|
65
|
+
reline (0.6.3)
|
|
66
|
+
io-console (~> 0.5)
|
|
72
67
|
simplecov (0.22.0)
|
|
73
68
|
docile (~> 1.1)
|
|
74
69
|
simplecov-html (~> 0.11)
|
|
75
70
|
simplecov_json_formatter (~> 0.1)
|
|
76
|
-
simplecov-html (0.13.
|
|
71
|
+
simplecov-html (0.13.2)
|
|
77
72
|
simplecov_json_formatter (0.1.4)
|
|
78
73
|
warning (1.5.0)
|
|
79
74
|
|
|
@@ -93,7 +88,7 @@ PLATFORMS
|
|
|
93
88
|
DEPENDENCIES
|
|
94
89
|
byebug
|
|
95
90
|
karafka-core!
|
|
96
|
-
|
|
91
|
+
minitest
|
|
97
92
|
simplecov
|
|
98
93
|
warning
|
|
99
94
|
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "bundler/gem_tasks"
|
|
5
|
+
|
|
6
|
+
require "minitest/test_task"
|
|
7
|
+
|
|
8
|
+
Minitest::TestTask.create(:test) do |t|
|
|
9
|
+
t.libs << "test"
|
|
10
|
+
t.libs << "lib"
|
|
11
|
+
t.warning = false
|
|
12
|
+
t.test_prelude = 'require "test_helper"'
|
|
13
|
+
t.test_globs = ["test/**/*_test.rb"]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
task default: :test
|
data/karafka-core.gemspec
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path(
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
|
6
|
-
require
|
|
6
|
+
require "karafka/core/version"
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |spec|
|
|
9
|
-
spec.name
|
|
10
|
-
spec.version
|
|
11
|
-
spec.platform
|
|
12
|
-
spec.authors
|
|
13
|
-
spec.email
|
|
14
|
-
spec.homepage
|
|
15
|
-
spec.summary
|
|
16
|
-
spec.description =
|
|
17
|
-
spec.licenses
|
|
9
|
+
spec.name = "karafka-core"
|
|
10
|
+
spec.version = Karafka::Core::VERSION
|
|
11
|
+
spec.platform = Gem::Platform::RUBY
|
|
12
|
+
spec.authors = ["Maciej Mensfeld"]
|
|
13
|
+
spec.email = %w[contact@karafka.io]
|
|
14
|
+
spec.homepage = "https://karafka.io"
|
|
15
|
+
spec.summary = "Karafka ecosystem core modules"
|
|
16
|
+
spec.description = "A toolset of small support modules used throughout the Karafka ecosystem"
|
|
17
|
+
spec.licenses = %w[MIT]
|
|
18
18
|
|
|
19
|
-
spec.add_dependency
|
|
20
|
-
spec.add_dependency
|
|
19
|
+
spec.add_dependency "karafka-rdkafka", ">= 0.20.0"
|
|
20
|
+
spec.add_dependency "logger", ">= 1.6.0"
|
|
21
21
|
|
|
22
|
-
spec.required_ruby_version =
|
|
22
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
23
23
|
|
|
24
|
-
spec.files
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
"homepage_uri" => "https://karafka.io",
|
|
29
|
+
"changelog_uri" => "https://karafka.io/docs/Changelog-Karafka-Core",
|
|
30
|
+
"bug_tracker_uri" => "https://github.com/karafka/karafka-core/issues",
|
|
31
|
+
"source_code_uri" => "https://github.com/karafka/karafka-core",
|
|
32
|
+
"documentation_uri" => "https://karafka.io/docs",
|
|
33
|
+
"rubygems_mfa_required" => "true"
|
|
34
34
|
}
|
|
35
35
|
end
|
|
@@ -36,10 +36,10 @@ module Karafka
|
|
|
36
36
|
# @param block [Proc] block for nested settings
|
|
37
37
|
def setting(node_name, default: nil, constructor: nil, lazy: false, &block)
|
|
38
38
|
@children << if block
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
Node.new(node_name, block)
|
|
40
|
+
else
|
|
41
|
+
Leaf.new(node_name, default, constructor, false, lazy)
|
|
42
|
+
end
|
|
43
43
|
|
|
44
44
|
compile
|
|
45
45
|
end
|
|
@@ -60,20 +60,20 @@ module Karafka
|
|
|
60
60
|
|
|
61
61
|
@children.each do |value|
|
|
62
62
|
config[value.node_name] = if value.is_a?(Leaf)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
|
|
71
|
+
# We need to check if value is not a result node for cases
|
|
72
|
+
# where we merge additional config
|
|
73
|
+
result.is_a?(Node) ? result.to_h : result
|
|
74
|
+
else
|
|
75
|
+
value.to_h
|
|
76
|
+
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
config.freeze
|
|
@@ -87,14 +87,14 @@ module Karafka
|
|
|
87
87
|
|
|
88
88
|
children.each do |value|
|
|
89
89
|
dupped.children << if value.is_a?(Leaf)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
dupped
|
|
@@ -116,19 +116,19 @@ module Karafka
|
|
|
116
116
|
next if skippable
|
|
117
117
|
|
|
118
118
|
initialized = if value.is_a?(Leaf)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
119
|
+
value.compiled = true
|
|
120
|
+
|
|
121
|
+
if value.constructor && value.lazy?
|
|
122
|
+
false
|
|
123
|
+
elsif value.constructor
|
|
124
|
+
call_constructor(value)
|
|
125
|
+
else
|
|
126
|
+
value.default
|
|
127
|
+
end
|
|
128
|
+
else
|
|
129
|
+
value.compile
|
|
130
|
+
value
|
|
131
|
+
end
|
|
132
132
|
|
|
133
133
|
if lazy_leaf && !initialized
|
|
134
134
|
build_dynamic_accessor(value)
|
|
@@ -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
|
|
|
@@ -51,16 +50,15 @@ module Karafka
|
|
|
51
50
|
|
|
52
51
|
# This will handle inheritance
|
|
53
52
|
@config = if superclass.respond_to?(:config)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
superclass.config.deep_dup
|
|
54
|
+
else
|
|
55
|
+
Node.new(:root)
|
|
56
|
+
end
|
|
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
64
|
# Pipes the settings setup to the config root node
|
|
@@ -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
|
|
|
@@ -127,7 +126,7 @@ module Karafka
|
|
|
127
126
|
|
|
128
127
|
# We need to compare `DIG_MISS` against stuff because of the ownership of the `#==`
|
|
129
128
|
# method
|
|
130
|
-
if
|
|
129
|
+
if for_checking == DIG_MISS
|
|
131
130
|
errors << [scope + rule.path, :missing]
|
|
132
131
|
else
|
|
133
132
|
result = rule.validator.call(for_checking, data, errors, self)
|
|
@@ -148,7 +147,7 @@ module Karafka
|
|
|
148
147
|
def validate_optional(data, rule, errors, scope)
|
|
149
148
|
for_checking = dig(data, rule.path)
|
|
150
149
|
|
|
151
|
-
return if
|
|
150
|
+
return if for_checking == DIG_MISS
|
|
152
151
|
|
|
153
152
|
result = rule.validator.call(for_checking, data, errors, self)
|
|
154
153
|
|
|
@@ -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)
|
|
@@ -26,14 +26,14 @@ module Karafka
|
|
|
26
26
|
hashed = {}
|
|
27
27
|
|
|
28
28
|
errors.each do |error|
|
|
29
|
-
scope = error.first.map(&:to_s).join(
|
|
29
|
+
scope = error.first.map(&:to_s).join(".").to_sym
|
|
30
30
|
|
|
31
31
|
# This will allow for usage of custom messages instead of yaml keys if needed
|
|
32
32
|
hashed[scope] = if error.last.is_a?(String)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
error.last
|
|
34
|
+
else
|
|
35
|
+
build_message(contract, scope, error.last)
|
|
36
|
+
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
@errors = hashed
|
|
@@ -56,7 +56,7 @@ module Karafka
|
|
|
56
56
|
messages = contract.class.config.error_messages
|
|
57
57
|
|
|
58
58
|
# Split scope into parts for progressive checking
|
|
59
|
-
scope_parts = scope.to_s.split(
|
|
59
|
+
scope_parts = scope.to_s.split(".")
|
|
60
60
|
|
|
61
61
|
# Try full scope first, then progressively remove from beginning
|
|
62
62
|
# This allows us to have full path scoped errors but can also be used as a fallback,
|
|
@@ -65,10 +65,10 @@ module Karafka
|
|
|
65
65
|
current_scope_parts = scope_parts[i..]
|
|
66
66
|
|
|
67
67
|
key = if current_scope_parts.empty?
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
error_key.to_s
|
|
69
|
+
else
|
|
70
|
+
"#{current_scope_parts.join(".")}_#{error_key}"
|
|
71
|
+
end
|
|
72
72
|
|
|
73
73
|
return messages[key] if messages.key?(key)
|
|
74
74
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "fileutils"
|
|
4
4
|
|
|
5
5
|
module Karafka
|
|
6
6
|
module Core
|
|
@@ -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
|
|
@@ -37,14 +37,14 @@ module Karafka
|
|
|
37
37
|
def inherited
|
|
38
38
|
caller(2..2)
|
|
39
39
|
.first
|
|
40
|
-
.split(
|
|
40
|
+
.split(":")
|
|
41
41
|
.first
|
|
42
|
-
.gsub(@specs_root_dir,
|
|
43
|
-
.gsub(
|
|
44
|
-
.split(
|
|
42
|
+
.gsub(@specs_root_dir, "")
|
|
43
|
+
.gsub("_spec.rb", "")
|
|
44
|
+
.split("/")
|
|
45
45
|
.delete_if(&:empty?)
|
|
46
46
|
.itself[1..]
|
|
47
|
-
.join(
|
|
47
|
+
.join("/")
|
|
48
48
|
.then { |path| custom_camelize(path) }
|
|
49
49
|
.then { |string| transform_inflections(string) }
|
|
50
50
|
.then { |class_name| custom_constantize(class_name) }
|
|
@@ -65,12 +65,12 @@ module Karafka
|
|
|
65
65
|
# @return [String] camel-case string
|
|
66
66
|
def custom_camelize(string)
|
|
67
67
|
# First, replace slashes with :: for proper namespacing
|
|
68
|
-
string = string.gsub(
|
|
68
|
+
string = string.gsub("/", "::")
|
|
69
69
|
|
|
70
70
|
# Then camelize each segment
|
|
71
71
|
string.gsub(/(?:^|_|::)([a-z])/) do |match|
|
|
72
72
|
# If it's a namespace separator, keep it and uppercase the following letter
|
|
73
|
-
if match.include?(
|
|
73
|
+
if match.include?("::")
|
|
74
74
|
"::#{match[-1].upcase}"
|
|
75
75
|
else
|
|
76
76
|
match[-1].upcase
|
|
@@ -82,7 +82,7 @@ module Karafka
|
|
|
82
82
|
# @param string [String] string representing a constant name
|
|
83
83
|
# @return [Class, Module] the constant
|
|
84
84
|
def custom_constantize(string)
|
|
85
|
-
names = string.split(
|
|
85
|
+
names = string.split("::")
|
|
86
86
|
constant = Object
|
|
87
87
|
regexp = /^[A-Z][a-zA-Z0-9_]*$/
|
|
88
88
|
|
|
@@ -6,7 +6,7 @@ module Karafka
|
|
|
6
6
|
module Helpers
|
|
7
7
|
# Time related methods used across Karafka
|
|
8
8
|
module Time
|
|
9
|
-
if RUBY_VERSION >=
|
|
9
|
+
if RUBY_VERSION >= "3.2"
|
|
10
10
|
# @return [Float] current monotonic time in milliseconds
|
|
11
11
|
def monotonic_now
|
|
12
12
|
::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :float_millisecond)
|
|
@@ -27,19 +27,15 @@ module Karafka
|
|
|
27
27
|
#
|
|
28
28
|
# @param event_id [String, Symbol] event id
|
|
29
29
|
# @param payload [Hash]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
full_event_name = @mapped_events[event_id] ||= [event_id, @namespace].compact.join('.')
|
|
30
|
+
def instrument(event_id, payload = EMPTY_HASH, &)
|
|
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
|