karafka 2.1.8 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 042f365fb134a24ae360d678590ce798014751c8a23fb267001c920a42aa5324
4
- data.tar.gz: ba2950de557a5f6c775577ce392d60ee839184f50b7d9225969c684625c9ecd0
3
+ metadata.gz: 65296040c91ec5646620f047567c9229b7d9044d41d37e690f9f6685d1199e36
4
+ data.tar.gz: dedea921e5bc3b9b985861d9b6bcf6c5b5de1a148ef2c1aa72b0d96de44fb623
5
5
  SHA512:
6
- metadata.gz: 30b5fcd92c348c50482cb84542380ad28b317d47e01efad2d2049cd3ba7872c5f66a7a4fde93d8bfa262d7fcb3745dedbdb89a4fd5e6cdf2288a43606ea2361d
7
- data.tar.gz: d9c8ba95b2b71f46a3d35e2f5be634473a7aa9f45d9b5924e1019dcb53c7cea6aca8c594f9f4d3bf85a14176c3cb98a7167b4eb6e1f6f2192059d8040440e4a9
6
+ metadata.gz: 781e45af707a9818e9166d6c37d8be214e9334703ee598f4ce8924c99ec71283cc4364de6662fbd1bb7454600b94b71e2e32750b58630e3631235e5bf593c3f9
7
+ data.tar.gz: b86b74c4d7909d504e0b60ae536360412622451a7a9868034dca63fbc3c5e962ba122967aeb8a1491196ce6b879b25eef11497798d861fcf85d3acca40fc8163
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Karafka framework changelog
2
2
 
3
+ ## 2.1.9 (2023-08-06)
4
+ - **[Feature]** Introduce ability to customize pause strategy on a per topic basis (Pro).
5
+ - [Improvement] Disable the extensive messages logging in the default `karafka.rb` template.
6
+ - [Change] Require `waterdrop` `>= 2.6.6` due to extra `LoggerListener` API.
7
+
3
8
  ## 2.1.8 (2023-07-29)
4
9
  - [Improvement] Introduce `Karafka::BaseConsumer#used?` method to indicate, that at least one invocation of `#consume` took or will take place. This can be used as a replacement to the non-direct `messages.count` check for shutdown and revocation to ensure, that the consumption took place or is taking place (in case of running LRJ).
5
10
  - [Improvement] Make `messages#to_a` return copy of the underlying array to prevent scenarios, where the mutation impacts offset management.
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (2.1.8)
4
+ karafka (2.1.9)
5
5
  karafka-core (>= 2.1.1, < 2.2.0)
6
6
  thor (>= 0.20)
7
- waterdrop (>= 2.6.2, < 3.0.0)
7
+ waterdrop (>= 2.6.6, < 3.0.0)
8
8
  zeitwerk (~> 2.3)
9
9
 
10
10
  GEM
@@ -72,7 +72,7 @@ GEM
72
72
  tilt (2.2.0)
73
73
  tzinfo (2.0.6)
74
74
  concurrent-ruby (~> 1.0)
75
- waterdrop (2.6.5)
75
+ waterdrop (2.6.6)
76
76
  karafka-core (>= 2.1.1, < 3.0.0)
77
77
  zeitwerk (~> 2.3)
78
78
  zeitwerk (2.6.8)
@@ -23,6 +23,11 @@ en:
23
23
  delaying.delay_format: 'needs to be equal or more than 0 and an integer'
24
24
  delaying.active_format: 'needs to be boolean'
25
25
 
26
+ pause_timeout_format: needs to be an integer bigger than 0
27
+ pause_max_timeout_format: needs to be an integer bigger than 0
28
+ pause_with_exponential_backoff_format: needs to be either true or false
29
+ pause_timeout_max_timeout_vs_pause_max_timeout: pause_timeout must be less or equal to pause_max_timeout
30
+
26
31
  config:
27
32
  encryption.active_format: 'needs to be either true or false'
28
33
  encryption.public_key_invalid: 'is not a valid public RSA key'
data/karafka.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'karafka-core', '>= 2.1.1', '< 2.2.0'
25
25
  spec.add_dependency 'thor', '>= 0.20'
26
- spec.add_dependency 'waterdrop', '>= 2.6.2', '< 3.0.0'
26
+ spec.add_dependency 'waterdrop', '>= 2.6.6', '< 3.0.0'
27
27
  spec.add_dependency 'zeitwerk', '~> 2.3'
28
28
 
29
29
  if $PROGRAM_NAME.end_with?('gem')
@@ -192,7 +192,7 @@ module Karafka
192
192
  # Resumes processing of partitions that were paused due to an error.
193
193
  def resume_paused_partitions
194
194
  @coordinators.resume do |topic, partition|
195
- @client.resume(topic, partition)
195
+ @client.resume(topic.name, partition)
196
196
  end
197
197
  end
198
198
 
@@ -14,20 +14,20 @@ module Karafka
14
14
 
15
15
  # Creates or fetches pause tracker of a given topic partition.
16
16
  #
17
- # @param topic [String] topic name
17
+ # @param topic [::Karafka::Routing::Topic] topic
18
18
  # @param partition [Integer] partition number
19
19
  # @return [Karafka::TimeTrackers::Pause] pause tracker instance
20
20
  def fetch(topic, partition)
21
21
  @pauses[topic][partition] ||= TimeTrackers::Pause.new(
22
- timeout: Karafka::App.config.pause_timeout,
23
- max_timeout: Karafka::App.config.pause_max_timeout,
24
- exponential_backoff: Karafka::App.config.pause_with_exponential_backoff
22
+ timeout: topic.pause_timeout,
23
+ max_timeout: topic.pause_max_timeout,
24
+ exponential_backoff: topic.pause_with_exponential_backoff
25
25
  )
26
26
  end
27
27
 
28
28
  # Resumes processing of partitions for which pause time has ended.
29
29
  #
30
- # @yieldparam [String] topic name
30
+ # @yieldparam [Karafka::Routing::Topic] topic
31
31
  # @yieldparam [Integer] partition number
32
32
  def resume
33
33
  @pauses.each do |topic, partitions|
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Pro
16
+ module Routing
17
+ module Features
18
+ class Pausing < Base
19
+ # Contract to make sure, that the pause settings on a per topic basis are as expected
20
+ class Contract < Contracts::Base
21
+ configure do |config|
22
+ config.error_messages = YAML.safe_load(
23
+ File.read(
24
+ File.join(Karafka.gem_root, 'config', 'locales', 'pro_errors.yml')
25
+ )
26
+ ).fetch('en').fetch('validations').fetch('topic')
27
+
28
+ required(:pause_timeout) { |val| val.is_a?(Integer) && val.positive? }
29
+ required(:pause_max_timeout) { |val| val.is_a?(Integer) && val.positive? }
30
+ required(:pause_with_exponential_backoff) { |val| [true, false].include?(val) }
31
+
32
+ virtual do |data, errors|
33
+ next unless errors.empty?
34
+
35
+ pause_timeout = data.fetch(:pause_timeout)
36
+ pause_max_timeout = data.fetch(:pause_max_timeout)
37
+
38
+ next if pause_timeout <= pause_max_timeout
39
+
40
+ [[%i[pause_timeout], :max_timeout_vs_pause_max_timeout]]
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Pro
16
+ module Routing
17
+ module Features
18
+ class Pausing < Base
19
+ # Expansion allowing for a per topic pause strategy definitions
20
+ module Topic
21
+ # Allows for per-topic pausing strategy setting
22
+ #
23
+ # @param timeout [Integer] how long should we wait upon processing error (milliseconds)
24
+ # @param max_timeout [Integer] what is the max timeout in case of an exponential
25
+ # backoff (milliseconds)
26
+ # @param with_exponential_backoff [Boolean] should we use exponential backoff
27
+ #
28
+ # @note We do not construct here the nested config like we do with other routing
29
+ # features, because this feature operates on the OSS layer by injection of values
30
+ # and a nested config is not needed.
31
+ def pause(timeout: nil, max_timeout: nil, with_exponential_backoff: nil)
32
+ self.pause_timeout = timeout if timeout
33
+ self.pause_max_timeout = max_timeout if max_timeout
34
+
35
+ return unless with_exponential_backoff
36
+
37
+ self.pause_with_exponential_backoff = with_exponential_backoff
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Pro
16
+ module Routing
17
+ module Features
18
+ # Feature allowing for a per-route reconfiguration of the pausing strategy
19
+ # It can be useful when different topics should have different backoff policies
20
+ class Pausing < Base
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -17,14 +17,18 @@ module Karafka
17
17
  @topics = topics
18
18
  end
19
19
 
20
- # @param topic [String] topic name
20
+ # @param topic_name [String] topic name
21
21
  # @param partition [Integer] partition number
22
- def find_or_create(topic, partition)
23
- @coordinators[topic][partition] ||= @coordinator_class.new(
24
- @topics.find(topic),
25
- partition,
26
- @pauses_manager.fetch(topic, partition)
27
- )
22
+ def find_or_create(topic_name, partition)
23
+ @coordinators[topic_name][partition] ||= begin
24
+ routing_topic = @topics.find(topic_name)
25
+
26
+ @coordinator_class.new(
27
+ routing_topic,
28
+ partition,
29
+ @pauses_manager.fetch(routing_topic, partition)
30
+ )
31
+ end
28
32
  end
29
33
 
30
34
  # Resumes processing of partitions for which pause time has ended.
@@ -35,16 +39,16 @@ module Karafka
35
39
  @pauses_manager.resume(&block)
36
40
  end
37
41
 
38
- # @param topic [String] topic name
42
+ # @param topic_name [String] topic name
39
43
  # @param partition [Integer] partition number
40
- def revoke(topic, partition)
41
- return unless @coordinators[topic].key?(partition)
44
+ def revoke(topic_name, partition)
45
+ return unless @coordinators[topic_name].key?(partition)
42
46
 
43
47
  # The fact that we delete here does not change the fact that the executor still holds the
44
48
  # reference to this coordinator. We delete it here, as we will no longer process any
45
49
  # new stuff with it and we may need a new coordinator if we regain this partition, but the
46
50
  # coordinator may still be in use
47
- @coordinators[topic].delete(partition).revoke
51
+ @coordinators[topic_name].delete(partition).revoke
48
52
  end
49
53
 
50
54
  # Clears coordinators and re-created the pauses manager
@@ -18,6 +18,9 @@ module Karafka
18
18
  max_wait_time
19
19
  initial_offset
20
20
  consumer_persistence
21
+ pause_timeout
22
+ pause_max_timeout
23
+ pause_with_exponential_backoff
21
24
  ].freeze
22
25
 
23
26
  private_constant :INHERITABLE_ATTRIBUTES
@@ -43,7 +43,13 @@ class KarafkaApp < Karafka::App
43
43
  # This logger prints the producer development info using the Karafka logger.
44
44
  # It is similar to the consumer logger listener but producer oriented.
45
45
  Karafka.producer.monitor.subscribe(
46
- WaterDrop::Instrumentation::LoggerListener.new(Karafka.logger)
46
+ WaterDrop::Instrumentation::LoggerListener.new(
47
+ # Log producer operations using the Karafka logger
48
+ Karafka.logger,
49
+ # If you set this to true, logs will contain each message details
50
+ # Please note, that this can be extensive
51
+ log_messages: false
52
+ )
47
53
  )
48
54
 
49
55
  routes.draw do
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '2.1.8'
6
+ VERSION = '2.1.9'
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.1.8
4
+ version: 2.1.9
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: 2023-07-29 00:00:00.000000000 Z
38
+ date: 2023-08-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka-core
@@ -77,7 +77,7 @@ dependencies:
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 2.6.2
80
+ version: 2.6.6
81
81
  - - "<"
82
82
  - !ruby/object:Gem::Version
83
83
  version: 3.0.0
@@ -87,7 +87,7 @@ dependencies:
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: 2.6.2
90
+ version: 2.6.6
91
91
  - - "<"
92
92
  - !ruby/object:Gem::Version
93
93
  version: 3.0.0
@@ -314,6 +314,9 @@ files:
314
314
  - lib/karafka/pro/routing/features/long_running_job/config.rb
315
315
  - lib/karafka/pro/routing/features/long_running_job/contract.rb
316
316
  - lib/karafka/pro/routing/features/long_running_job/topic.rb
317
+ - lib/karafka/pro/routing/features/pausing.rb
318
+ - lib/karafka/pro/routing/features/pausing/contract.rb
319
+ - lib/karafka/pro/routing/features/pausing/topic.rb
317
320
  - lib/karafka/pro/routing/features/throttling.rb
318
321
  - lib/karafka/pro/routing/features/throttling/config.rb
319
322
  - lib/karafka/pro/routing/features/throttling/contract.rb
metadata.gz.sig CHANGED
Binary file