karafka 2.2.1 → 2.2.2

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: a96aaf1f1cc1fadbeb09477a107efc11319f288b0e5d94f959813d7f85d295bf
4
- data.tar.gz: b0db0711ceb51856771ba6906c0868f51637d78bd785c25005408449d32a3302
3
+ metadata.gz: 440133344045600ff04e132d48e16b83ce492d06616383f02f3c282ec28cd239
4
+ data.tar.gz: e12def9a87bf4e731bc049f15352c86ed95bdcd970ac4081cc720bd268e99d26
5
5
  SHA512:
6
- metadata.gz: 7c37db7c2de5b131f34c08fe73e4453ea81d0ec99b4a5764b41ca98c7c8ff064b1b9f8bfee5e26bbae267ca77b3b5e72d72d90c9b4e034c6ead0d90b931f1fa9
7
- data.tar.gz: 55131983670c0454f3f5a23df2b0d90b8718455f8f331ee660cd20dd3f131540188149f36efbb7842fe1561de4cb7f85d8892477deefbd1eb0c071722f2ffa72
6
+ metadata.gz: 2c9deb6fdd1172e4a40828d8650d016e0cd660e3c3f4a98ab9bf6abcb2ce77179206e7d898ddfce4379fea994c4f7e3840a2a5b768648f13aa11504efd55feb0
7
+ data.tar.gz: 3543d19c5066d144d0d9a15d366d522e5b0134a3df601ef01e416659d71d07d977fef2e71d170dfa5382f8ce496ed554dd004b45bf936d472b2aab75ef473ac5
checksums.yaml.gz.sig CHANGED
Binary file
@@ -18,7 +18,7 @@ jobs:
18
18
  strategy:
19
19
  fail-fast: false
20
20
  steps:
21
- - uses: actions/checkout@v3
21
+ - uses: actions/checkout@v4
22
22
  with:
23
23
  fetch-depth: 0
24
24
 
@@ -39,7 +39,7 @@ jobs:
39
39
  strategy:
40
40
  fail-fast: false
41
41
  steps:
42
- - uses: actions/checkout@v3
42
+ - uses: actions/checkout@v4
43
43
  with:
44
44
  fetch-depth: 0
45
45
  - name: Run Karafka license checksum verification
@@ -55,7 +55,7 @@ jobs:
55
55
  strategy:
56
56
  fail-fast: false
57
57
  steps:
58
- - uses: actions/checkout@v3
58
+ - uses: actions/checkout@v4
59
59
  with:
60
60
  fetch-depth: 0
61
61
  - name: Run Coditsu
@@ -82,7 +82,7 @@ jobs:
82
82
  - ruby: '3.2'
83
83
  coverage: 'true'
84
84
  steps:
85
- - uses: actions/checkout@v3
85
+ - uses: actions/checkout@v4
86
86
  - name: Install package dependencies
87
87
  run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
88
88
 
@@ -117,7 +117,7 @@ jobs:
117
117
  - ruby: '3.2'
118
118
  coverage: 'true'
119
119
  steps:
120
- - uses: actions/checkout@v3
120
+ - uses: actions/checkout@v4
121
121
  - name: Install package dependencies
122
122
  run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
123
123
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Karafka framework changelog
2
2
 
3
+ ## 2.2.2 (2023-09-11)
4
+ - [Feature] Provide ability to define routing defaults.
5
+ - [Maintenance] Require `karafka-core` `>=` `2.2.2`
6
+
3
7
  ## 2.2.1 (2023-09-01)
4
8
  - [Fix] Fix insufficient validation of named patterns
5
9
  - [Maintenance] Rely on `2.2.x` `karafka-core`.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (2.2.1)
5
- karafka-core (>= 2.2.0, < 2.3.0)
4
+ karafka (2.2.2)
5
+ karafka-core (>= 2.2.2, < 2.3.0)
6
6
  thor (>= 0.20)
7
7
  waterdrop (>= 2.6.6, < 3.0.0)
8
8
  zeitwerk (~> 2.3)
@@ -30,7 +30,7 @@ GEM
30
30
  activesupport (>= 5.0)
31
31
  i18n (1.14.1)
32
32
  concurrent-ruby (~> 1.0)
33
- karafka-core (2.2.0)
33
+ karafka-core (2.2.2)
34
34
  concurrent-ruby (>= 1.1)
35
35
  karafka-rdkafka (>= 0.13.1, < 0.14.0)
36
36
  karafka-rdkafka (0.13.4)
data/karafka.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  without having to focus on things that are not your business domain.
22
22
  DESC
23
23
 
24
- spec.add_dependency 'karafka-core', '>= 2.2.0', '< 2.3.0'
24
+ spec.add_dependency 'karafka-core', '>= 2.2.2', '< 2.3.0'
25
25
  spec.add_dependency 'thor', '>= 0.20'
26
26
  spec.add_dependency 'waterdrop', '>= 2.6.6', '< 3.0.0'
27
27
  spec.add_dependency 'zeitwerk', '~> 2.3'
@@ -10,8 +10,14 @@ module Karafka
10
10
  # end
11
11
  # end
12
12
  class Builder < Concurrent::Array
13
+ # Empty default per-topic config
14
+ EMPTY_DEFAULTS = ->(_) {}.freeze
15
+
16
+ private_constant :EMPTY_DEFAULTS
17
+
13
18
  def initialize
14
19
  @draws = Concurrent::Array.new
20
+ @defaults = EMPTY_DEFAULTS
15
21
  super
16
22
  end
17
23
 
@@ -55,10 +61,19 @@ module Karafka
55
61
 
56
62
  # Clears the builder and the draws memory
57
63
  def clear
64
+ @defaults = EMPTY_DEFAULTS
58
65
  @draws.clear
59
66
  super
60
67
  end
61
68
 
69
+ # @param block [Proc] block with per-topic evaluated defaults
70
+ # @return [Proc] defaults that should be evaluated per topic
71
+ def defaults(&block)
72
+ return @defaults unless block
73
+
74
+ @defaults = block
75
+ end
76
+
62
77
  private
63
78
 
64
79
  # Builds and saves given consumer group
@@ -22,7 +22,7 @@ module Karafka
22
22
  # kafka and don't understand the concept of consumer groups.
23
23
  def initialize(name)
24
24
  @name = name.to_s
25
- @id = Karafka::App.config.consumer_mapper.call(name)
25
+ @id = config.consumer_mapper.call(name)
26
26
  @topics = Topics.new([])
27
27
  # Initialize the subscription group so there's always a value for it, since even if not
28
28
  # defined directly, a subscription group will be created
@@ -31,7 +31,7 @@ module Karafka
31
31
 
32
32
  # @return [Boolean] true if this consumer group should be active in our current process
33
33
  def active?
34
- Karafka::App.config.internal.routing.activity_manager.active?(:consumer_groups, name)
34
+ config.internal.routing.activity_manager.active?(:consumer_groups, name)
35
35
  end
36
36
 
37
37
  # Builds a topic representation inside of a current consumer group route
@@ -40,7 +40,11 @@ module Karafka
40
40
  # @return [Karafka::Routing::Topic] newly built topic instance
41
41
  def topic=(name, &block)
42
42
  topic = Topic.new(name, self)
43
- @topics << Proxy.new(topic, &block).target
43
+ @topics << Proxy.new(
44
+ topic,
45
+ config.internal.routing.builder.defaults,
46
+ &block
47
+ ).target
44
48
  built_topic = @topics.last
45
49
  # We overwrite it conditionally in case it was not set by the user inline in the topic
46
50
  # block definition
@@ -67,8 +71,7 @@ module Karafka
67
71
  # @return [Array<Routing::SubscriptionGroup>] all the subscription groups build based on
68
72
  # the consumer group topics
69
73
  def subscription_groups
70
- @subscription_groups ||= App
71
- .config
74
+ @subscription_groups ||= config
72
75
  .internal
73
76
  .routing
74
77
  .subscription_groups_builder
@@ -84,6 +87,13 @@ module Karafka
84
87
  id: id
85
88
  }.freeze
86
89
  end
90
+
91
+ private
92
+
93
+ # @return [Karafka::Core::Configurable::Node] root node config
94
+ def config
95
+ ::Karafka::App.config
96
+ end
87
97
  end
88
98
  end
89
99
  end
@@ -8,10 +8,13 @@ module Karafka
8
8
  attr_reader :target
9
9
 
10
10
  # @param target [Object] target object to which we proxy any DSL call
11
+ # @param defaults [Proc] defaults for target that should be applicable after the proper
12
+ # proxy context (if needed)
11
13
  # @param block [Proc] block that we want to evaluate in the proxy context
12
- def initialize(target, &block)
14
+ def initialize(target, defaults = ->(_) {}, &block)
13
15
  @target = target
14
16
  instance_eval(&block)
17
+ instance_eval(&defaults)
15
18
  end
16
19
 
17
20
  # Ruby 2.7.0 to 2.7.2 do not have arg forwarding, so we fallback to the old way
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '2.2.1'
6
+ VERSION = '2.2.2'
7
7
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
36
36
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
37
37
  -----END CERTIFICATE-----
38
- date: 2023-09-01 00:00:00.000000000 Z
38
+ date: 2023-09-11 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka-core
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.2.0
46
+ version: 2.2.2
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
49
  version: 2.3.0
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.2.0
56
+ version: 2.2.2
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
59
  version: 2.3.0
metadata.gz.sig CHANGED
Binary file