karafka-core 2.0.6 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4405dd3063f0901a0e362e4af4d518a36d9222e0b0bc653e6214789649d1aedc
4
- data.tar.gz: 3989835a62bb524675548bd8d04b8b8b3f9fad027879b4a063f09c3776cc66a2
3
+ metadata.gz: 89262ad9172da20cb645406674d90025637d7f4aea8e73379d2d39d475ed9eaf
4
+ data.tar.gz: f10d0f1748fc69859c9b1661c490304d23e8506f550eff2bc7446045d9fd2ff1
5
5
  SHA512:
6
- metadata.gz: f016129dc7b5dd6cd7bbf545025731674fd9252756b65db02f0ad01da5c88555b0f2b382e8687b767936e71c9b0f15f8de197ab2d22e551342aac5d61958cb15
7
- data.tar.gz: d806ccc59909f9650deea4284b9262bf4644749aa5e0a206ecd835d7b4b1e97fdd3292a84ddbb0292a23a3fd8106c20b42b52eff8021a9488253d409b911be44
6
+ metadata.gz: 3042fe634fccbcbb9e9331c0fab4b6637d8077c7cbd3695aa2802aac8b2d230be21eb1093bf4803886402a0bec292bd40078a74f115a85e532470378aaf3fd31
7
+ data.tar.gz: 46d394f39d1cdecb581e92f6786ee6780b7aa3ca80815337f7638441e0b3e6ce3bb477e09a0c89bc285d77acc1803a2b0393d8b63e68c75f14be694bf1c53c11
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- ���5�~���h)R�۹/�̡���3Y��LAur�X�Axb�"��p�\�ޖ]�p�m��t*�@���E�5ϙ����!D�(E�i��8v S���ڰ
2
- ���2Ni�`�Rh ����BڌFII��̑*d2����xvG��Y5���^܀�Rj����Z0 n�Ն�/��<gq��$�QzVw"��1��u������s�|�`�� �)�Fs[g]Г&���Ӓ�`�
3
- �>�y��"Ӵ�4Xy���Md����Iqm.��D�T�%"�hT��-Z
1
+ �U 4��aJ�@� H
2
+ ZP&�]��ow�<s8}^�k'l'���Wi�;�X��É[G��0_��㕽�#�
3
+ �����v������S ��K�@߲�R���5a�R���׶.�Om����"~?�kh�1������x̂�,P�.����L��-U6l �~pђ���Mɇ*4������DLe�NNp�1�n����Z���st1�D��R2,wأ����� v�:!M�Ә�#��F/���bn������lRPrAc#n/��<Z��_O��v�0�:�RvJ�����YG���;4H�&�0,ɶR����]xA�P�����ah."�c�3l�ޑ�SUI0�j��
@@ -16,11 +16,12 @@ jobs:
16
16
  fail-fast: false
17
17
  matrix:
18
18
  ruby:
19
+ - '3.2'
19
20
  - '3.1'
20
21
  - '3.0'
21
22
  - '2.7'
22
23
  include:
23
- - ruby: '3.1'
24
+ - ruby: '3.2'
24
25
  coverage: 'true'
25
26
  steps:
26
27
  - uses: actions/checkout@v3
@@ -54,7 +55,7 @@ jobs:
54
55
  - name: Set up Ruby
55
56
  uses: ruby/setup-ruby@v1
56
57
  with:
57
- ruby-version: 3.1
58
+ ruby-version: 3.2
58
59
  - name: Install latest bundler
59
60
  run: gem install bundler --no-document
60
61
  - name: Install Diffend plugin
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.3
1
+ 3.2.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Karafka core changelog
2
2
 
3
+ ## 2.0.8 (2023-01-07)
4
+ - Add `Karafka::Core::Helpers::Time` utility for time reporting.
5
+
6
+ ## 2.0.7 (2022-12-18)
7
+ - Allow for recompilation of config upon injecting new config nodes.
8
+ - Compile given config scope automatically after it is defined.
9
+ - Support sub-config merging via their nested definitions.
10
+
3
11
  ## 2.0.6 (2022-12-07)
4
12
  - Reverse node compilation state tracking removal.
5
13
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-core (2.0.6)
4
+ karafka-core (2.0.8)
5
5
  concurrent-ruby (>= 1.1)
6
6
  rdkafka (>= 0.12)
7
7
 
@@ -22,8 +22,8 @@ GEM
22
22
  ffi (1.15.5)
23
23
  i18n (1.12.0)
24
24
  concurrent-ruby (~> 1.0)
25
- mini_portile2 (2.8.0)
26
- minitest (5.16.3)
25
+ mini_portile2 (2.8.1)
26
+ minitest (5.17.0)
27
27
  rake (13.0.6)
28
28
  rdkafka (0.12.0)
29
29
  ffi (~> 1.15)
@@ -35,14 +35,14 @@ GEM
35
35
  rspec-mocks (~> 3.12.0)
36
36
  rspec-core (3.12.0)
37
37
  rspec-support (~> 3.12.0)
38
- rspec-expectations (3.12.0)
38
+ rspec-expectations (3.12.1)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
40
  rspec-support (~> 3.12.0)
41
- rspec-mocks (3.12.0)
41
+ rspec-mocks (3.12.1)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
43
  rspec-support (~> 3.12.0)
44
44
  rspec-support (3.12.0)
45
- simplecov (0.21.2)
45
+ simplecov (0.22.0)
46
46
  docile (~> 1.1)
47
47
  simplecov-html (~> 0.11)
48
48
  simplecov_json_formatter (~> 0.1)
@@ -63,4 +63,4 @@ DEPENDENCIES
63
63
  simplecov
64
64
 
65
65
  BUNDLED WITH
66
- 2.3.26
66
+ 2.4.2
File without changes
@@ -4,7 +4,12 @@ module Karafka
4
4
  module Core
5
5
  module Configurable
6
6
  # Single end config value representation
7
- Leaf = Struct.new(:name, :default, :constructor)
7
+ Leaf = Struct.new(:name, :default, :constructor, :compiled) do
8
+ # @return [Boolean] true if already compiled
9
+ def compiled?
10
+ compiled
11
+ end
12
+ end
8
13
  end
9
14
  end
10
15
  end
@@ -35,8 +35,10 @@ module Karafka
35
35
  @children << if block
36
36
  Node.new(name, block)
37
37
  else
38
- Leaf.new(name, default, constructor)
38
+ Leaf.new(name, default, constructor, false)
39
39
  end
40
+
41
+ compile
40
42
  end
41
43
 
42
44
  # Allows for the configuration and setup of the settings
@@ -44,7 +46,7 @@ module Karafka
44
46
  # Compile settings, allow for overrides via yielding
45
47
  # @return [Node] returns self after configuration
46
48
  def configure
47
- compile unless @compiled
49
+ compile if !@compiled || name == :root
48
50
  yield(self) if block_given?
49
51
  self
50
52
  end
@@ -55,7 +57,10 @@ module Karafka
55
57
 
56
58
  @children.each do |value|
57
59
  config[value.name] = if value.is_a?(Leaf)
58
- public_send(value.name)
60
+ result = public_send(value.name)
61
+ # We need to check if value is not a result node for cases where
62
+ # we merge additional config
63
+ result.is_a?(Node) ? result.to_h : result
59
64
  else
60
65
  value.to_h
61
66
  end
@@ -71,7 +76,14 @@ module Karafka
71
76
  dupped = Node.new(name, nestings)
72
77
 
73
78
  dupped.children += children.map do |value|
74
- value.is_a?(Leaf) ? value.dup : value.deep_dup
79
+ if value.is_a?(Leaf)
80
+ # After inheritance we need to reload the state so the leafs are recompiled again
81
+ value = value.dup
82
+ value.compiled = false
83
+ value
84
+ else
85
+ value.deep_dup
86
+ end
75
87
  end
76
88
 
77
89
  dupped
@@ -90,6 +102,9 @@ module Karafka
90
102
  next if skippable
91
103
 
92
104
  initialized = if value.is_a?(Leaf)
105
+ next if value.compiled?
106
+
107
+ value.compiled = true
93
108
  value.constructor ? value.constructor.call(value.default) : value.default
94
109
  else
95
110
  value.compile
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Core
5
+ # Namespace for some small utilities used across the ecosystem
6
+ module Helpers
7
+ # Time related methods used across Karafka
8
+ module Time
9
+ # @return [Float] current monotonic time in milliseconds
10
+ def monotonic_now
11
+ ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) * 1_000
12
+ end
13
+
14
+ # @return [Float] current time in float
15
+ def float_now
16
+ ::Time.now.utc.to_f
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -9,6 +9,8 @@ module Karafka
9
9
  # We do not use any of them by default as our use-case is fairly simple and we do not want
10
10
  # to have too many external dependencies.
11
11
  class Notifications
12
+ include Core::Helpers::Time
13
+
12
14
  attr_reader :name
13
15
 
14
16
  # Raised when someone wants to publish event that was not registered
@@ -112,14 +114,9 @@ module Karafka
112
114
  # Measures time taken to execute a given block and returns it together with the result of
113
115
  # the block execution
114
116
  def measure_time_taken
115
- start = current_time
117
+ start = monotonic_now
116
118
  result = yield
117
- [result, current_time - start]
118
- end
119
-
120
- # @return [Integer] current monotonic time
121
- def current_time
122
- ::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :millisecond)
119
+ [result, monotonic_now - start]
123
120
  end
124
121
  end
125
122
  end
@@ -4,6 +4,6 @@ module Karafka
4
4
  module Core
5
5
  # Current Karafka::Core version
6
6
  # We follow the versioning schema of given Karafka version
7
- VERSION = '2.0.6'
7
+ VERSION = '2.0.8'
8
8
  end
9
9
  end
data/lib/karafka-core.rb CHANGED
@@ -11,6 +11,8 @@
11
11
  karafka/core
12
12
  karafka/core/version
13
13
 
14
+ karafka/core/helpers/time
15
+
14
16
  karafka/core/monitoring
15
17
  karafka/core/monitoring/event
16
18
  karafka/core/monitoring/monitor
data.tar.gz.sig CHANGED
Binary file
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.0.6
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
36
36
  MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
37
37
  -----END CERTIFICATE-----
38
- date: 2022-12-07 00:00:00.000000000 Z
38
+ date: 2023-01-07 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: concurrent-ruby
@@ -90,7 +90,7 @@ files:
90
90
  - MIT-LICENSE
91
91
  - README.md
92
92
  - certs/cert_chain.pem
93
- - config/errors.yml
93
+ - config/locales/errors.yml
94
94
  - karafka-core.gemspec
95
95
  - lib/karafka-core.rb
96
96
  - lib/karafka/core.rb
@@ -101,6 +101,7 @@ files:
101
101
  - lib/karafka/core/contractable/contract.rb
102
102
  - lib/karafka/core/contractable/result.rb
103
103
  - lib/karafka/core/contractable/rule.rb
104
+ - lib/karafka/core/helpers/time.rb
104
105
  - lib/karafka/core/instrumentation.rb
105
106
  - lib/karafka/core/instrumentation/callbacks_manager.rb
106
107
  - lib/karafka/core/monitoring.rb
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  requirements: []
140
- rubygems_version: 3.3.26
141
+ rubygems_version: 3.4.1
141
142
  signing_key:
142
143
  specification_version: 4
143
144
  summary: Karafka ecosystem core modules
metadata.gz.sig CHANGED
Binary file