karafka 1.4.0 → 1.4.1

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: 45788f5dd509d8a61a1480ff5c1b41f89b683d2100e0dcedaf6e35e6ce3af447
4
- data.tar.gz: d5e5638fd2a83b91f78cf1f38d03bd2594fb562a0cc8ad6cf2e45f60e72cc692
3
+ metadata.gz: 7bae0f63af5f741dc00d382e34a0a5a35262692c9b03930dc18fd05440bf418b
4
+ data.tar.gz: f9a82e8ee1324b62820f24e8dddd09fdd1ec153c50a32f4f31f50a9192983341
5
5
  SHA512:
6
- metadata.gz: 75b2863022df6dc78f23ca557450a9757e137d110f9a6c49a29f572cd701863143e638394c341e8f982bdce4255df923879c8410ce081503c43e3f9a0ce2e777
7
- data.tar.gz: ec0eee525c34634d15b04c85a492e329d4749f179ff2c21d3ce2e50cccb4b6d061465c13df322a026b8924974f743277448464db818e13d73ef90f5ce930f796
6
+ metadata.gz: a8fecf4be83990908c8aaf6b1e0f262391e9cdd65079362f76f68871d9ec3f45e4c0e9ceb1b277036de7f4c6ab2c140e52ee4ad855ec150c64626e9728a650a6
7
+ data.tar.gz: 2b626896aad5bc96bce14f0943a8d9c279dd877d2a221994f2ae56031d0bc97a33e5696b892bc8224f1c527a27e0861a79aaedd4b7716286528f6baf8f00de04
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
@@ -1,5 +1,9 @@
1
1
  # Karafka framework changelog
2
2
 
3
+ ## 1.4.1 (2020-12-04)
4
+ - Return non-zero exit code when printing usage
5
+ - Add support for :assignment_strategy for consumers
6
+
3
7
  ## 1.4.0 (2020-09-05)
4
8
  - Rename `Karafka::Params::Metadata` to `Karafka::Params::BatchMetadata`
5
9
  ` Rename consumer `#metadata` to `#batch_metadata`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (1.4.0)
4
+ karafka (1.4.1)
5
5
  dry-configurable (~> 0.8)
6
6
  dry-inflector (~> 0.1)
7
7
  dry-monitor (~> 0.3)
@@ -17,7 +17,7 @@ PATH
17
17
  GEM
18
18
  remote: https://rubygems.org/
19
19
  specs:
20
- activesupport (6.0.3.2)
20
+ activesupport (6.0.3.4)
21
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
22
  i18n (>= 0.7, < 2)
23
23
  minitest (~> 5.1)
@@ -39,7 +39,7 @@ GEM
39
39
  dry-container (0.7.2)
40
40
  concurrent-ruby (~> 1.0)
41
41
  dry-configurable (~> 0.1, >= 0.1.3)
42
- dry-core (0.4.9)
42
+ dry-core (0.4.10)
43
43
  concurrent-ruby (~> 1.0)
44
44
  dry-equalizer (0.3.0)
45
45
  dry-events (0.2.0)
@@ -47,8 +47,8 @@ GEM
47
47
  dry-core (~> 0.4)
48
48
  dry-equalizer (~> 0.2)
49
49
  dry-inflector (0.2.0)
50
- dry-initializer (3.0.3)
51
- dry-logic (1.0.7)
50
+ dry-initializer (3.0.4)
51
+ dry-logic (1.0.8)
52
52
  concurrent-ruby (~> 1.0)
53
53
  dry-core (~> 0.2)
54
54
  dry-equalizer (~> 0.2)
@@ -57,7 +57,7 @@ GEM
57
57
  dry-core (~> 0.4)
58
58
  dry-equalizer (~> 0.2)
59
59
  dry-events (~> 0.2)
60
- dry-schema (1.5.4)
60
+ dry-schema (1.5.6)
61
61
  concurrent-ruby (~> 1.0)
62
62
  dry-configurable (~> 0.8, >= 0.8.3)
63
63
  dry-core (~> 0.4)
@@ -86,35 +86,37 @@ GEM
86
86
  i18n (1.8.5)
87
87
  concurrent-ruby (~> 1.0)
88
88
  io-console (0.5.6)
89
- irb (1.2.4)
90
- reline (>= 0.0.1)
89
+ irb (1.2.7)
90
+ reline (>= 0.1.5)
91
91
  king_konf (0.3.7)
92
92
  minitest (5.14.2)
93
93
  rake (13.0.1)
94
- reline (0.1.4)
94
+ reline (0.1.9)
95
95
  io-console (~> 0.5)
96
- rspec (3.9.0)
97
- rspec-core (~> 3.9.0)
98
- rspec-expectations (~> 3.9.0)
99
- rspec-mocks (~> 3.9.0)
100
- rspec-core (3.9.2)
101
- rspec-support (~> 3.9.3)
102
- rspec-expectations (3.9.2)
96
+ rspec (3.10.0)
97
+ rspec-core (~> 3.10.0)
98
+ rspec-expectations (~> 3.10.0)
99
+ rspec-mocks (~> 3.10.0)
100
+ rspec-core (3.10.0)
101
+ rspec-support (~> 3.10.0)
102
+ rspec-expectations (3.10.0)
103
103
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.9.0)
105
- rspec-mocks (3.9.1)
104
+ rspec-support (~> 3.10.0)
105
+ rspec-mocks (3.10.0)
106
106
  diff-lcs (>= 1.2.0, < 2.0)
107
- rspec-support (~> 3.9.0)
108
- rspec-support (3.9.3)
109
- ruby-kafka (1.2.0)
107
+ rspec-support (~> 3.10.0)
108
+ rspec-support (3.10.0)
109
+ ruby-kafka (1.3.0)
110
110
  digest-crc
111
- simplecov (0.19.0)
111
+ simplecov (0.20.0)
112
112
  docile (~> 1.1)
113
113
  simplecov-html (~> 0.11)
114
- simplecov-html (0.12.2)
114
+ simplecov_json_formatter (~> 0.1)
115
+ simplecov-html (0.12.3)
116
+ simplecov_json_formatter (0.1.2)
115
117
  thor (1.0.1)
116
118
  thread_safe (0.3.6)
117
- tzinfo (1.2.7)
119
+ tzinfo (1.2.8)
118
120
  thread_safe (~> 0.1)
119
121
  waterdrop (1.4.0)
120
122
  delivery_boy (>= 0.2, < 2.x)
@@ -123,7 +125,7 @@ GEM
123
125
  dry-validation (~> 1.2)
124
126
  ruby-kafka (>= 0.7.8)
125
127
  zeitwerk (~> 2.1)
126
- zeitwerk (2.4.0)
128
+ zeitwerk (2.4.2)
127
129
 
128
130
  PLATFORMS
129
131
  ruby
@@ -37,3 +37,5 @@ en:
37
37
  Unknown consumer group
38
38
  does_not_exist:
39
39
  Given file does not exist or cannot be read
40
+ does_not_respond_to_call: >
41
+ needs to respond to a #call method
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ # Strategies for Kafka partitions assignments
5
+ module AssignmentStrategies
6
+ # Standard RoundRobin strategy
7
+ class RoundRobin < SimpleDelegator
8
+ def initialize
9
+ super(Kafka::RoundRobinAssignmentStrategy.new)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -19,6 +19,7 @@ module Karafka
19
19
  consumer: %i[
20
20
  session_timeout offset_commit_interval offset_commit_threshold
21
21
  offset_retention_time heartbeat_interval fetcher_max_queue_size
22
+ assignment_strategy
22
23
  ],
23
24
  subscribe: %i[start_from_beginning max_bytes_per_partition],
24
25
  consumption: %i[min_bytes max_bytes max_wait_time],
@@ -10,6 +10,8 @@ module Karafka
10
10
  class Cli < Thor
11
11
  package_name 'Karafka'
12
12
 
13
+ default_task :missingno
14
+
13
15
  class << self
14
16
  # Loads all Cli commands into Thor framework
15
17
  # This method should be executed before we run Karafka::Cli.start, otherwise we won't
@@ -20,6 +22,12 @@ module Karafka
20
22
  end
21
23
  end
22
24
 
25
+ # When there is a CLI crash, exit
26
+ # @return [true]
27
+ def exit_on_failure?
28
+ true
29
+ end
30
+
23
31
  private
24
32
 
25
33
  # @return [Array<Class>] Array with Cli action classes that can be used as commands
@@ -43,16 +43,16 @@ module Karafka
43
43
  end
44
44
 
45
45
  # Allows to set description of a given cli command
46
- # @param desc [String] Description of a given cli command
47
- def desc(desc)
48
- @desc ||= desc
46
+ # @param args [Array] All the arguments that Thor desc method accepts
47
+ def desc(*args)
48
+ @desc ||= args
49
49
  end
50
50
 
51
51
  # This method will bind a given Cli command into Karafka Cli
52
52
  # This method is a wrapper to way Thor defines its commands
53
53
  # @param cli_class [Karafka::Cli] Karafka cli_class
54
54
  def bind_to(cli_class)
55
- cli_class.desc name, @desc
55
+ cli_class.desc name, *@desc
56
56
 
57
57
  (@options || []).each { |option| cli_class.option(*option) }
58
58
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ class Cli < Thor
5
+ # Command that gets invoked when no method is provided when running the CLI
6
+ # It allows us to exit with exit code 1 instead of default 0 to indicate that something
7
+ # was missing
8
+ # @see https://github.com/karafka/karafka/issues/619
9
+ class Missingno < Base
10
+ desc 'Hidden command that gets invoked when no command is provided', hide: true
11
+
12
+ # Prints an error about the lack of command (nothing selected)
13
+ def call
14
+ Karafka.logger.error('No command provided')
15
+ exit 1
16
+ end
17
+ end
18
+ end
19
+ end
@@ -5,6 +5,6 @@ module Karafka
5
5
  module Contracts
6
6
  # Regexp for validating format of groups and topics
7
7
  # @note It is not nested inside of the contracts, as it is used by couple of them
8
- TOPIC_REGEXP = /\A(\w|\-|\.)+\z/.freeze
8
+ TOPIC_REGEXP = /\A(\w|-|\.)+\z/.freeze
9
9
  end
10
10
  end
@@ -32,6 +32,7 @@ module Karafka
32
32
  required(:offset_retention_time).maybe(:integer)
33
33
  required(:heartbeat_interval).filled { (int? | float?) & gteq?(0) }
34
34
  required(:fetcher_max_queue_size).filled(:int?, gt?: 0)
35
+ required(:assignment_strategy).value(:any)
35
36
  required(:connect_timeout).filled { (int? | float?) & gt?(0) }
36
37
  required(:reconnect_timeout).filled { (int? | float?) & gteq?(0) }
37
38
  required(:socket_timeout).filled { (int? | float?) & gt?(0) }
@@ -70,13 +71,13 @@ module Karafka
70
71
 
71
72
  # Uri rule to check if uri is in a Karafka acceptable format
72
73
  rule(:seed_brokers) do
73
- if value&.is_a?(Array) && !value.all?(&method(:kafka_uri?))
74
+ if value.is_a?(Array) && !value.all?(&method(:kafka_uri?))
74
75
  key.failure(:invalid_broker_schema)
75
76
  end
76
77
  end
77
78
 
78
79
  rule(:topics) do
79
- if value&.is_a?(Array)
80
+ if value.is_a?(Array)
80
81
  names = value.map { |topic| topic[:name] }
81
82
 
82
83
  key.failure(:topics_names_not_unique) if names.size != names.uniq.size
@@ -84,7 +85,7 @@ module Karafka
84
85
  end
85
86
 
86
87
  rule(:topics) do
87
- if value&.is_a?(Array)
88
+ if value.is_a?(Array)
88
89
  value.each_with_index do |topic, index|
89
90
  TOPIC_CONTRACT.call(topic).errors.each do |error|
90
91
  key([:topics, index, error.path[0]]).failure(error.text)
@@ -93,6 +94,10 @@ module Karafka
93
94
  end
94
95
  end
95
96
 
97
+ rule(:assignment_strategy) do
98
+ key.failure(:does_not_respond_to_call) unless value.respond_to?(:call)
99
+ end
100
+
96
101
  rule(:ssl_client_cert, :ssl_client_cert_key) do
97
102
  if values[:ssl_client_cert] && !values[:ssl_client_cert_key]
98
103
  key(:ssl_client_cert_key).failure(:ssl_client_cert_with_ssl_client_cert_key)
@@ -8,7 +8,7 @@ module Karafka
8
8
  class ClassMatcher
9
9
  # Regexp used to remove any non classy like characters that might be in the consumer
10
10
  # class name (if defined dynamically, etc)
11
- CONSTANT_REGEXP = %r{[?!=+\-\*/\^\|&\[\]<>%~\#\:\s\(\)]}.freeze
11
+ CONSTANT_REGEXP = %r{[?!=+\-*/\^|&\[\]<>%~\#:\s()]}.freeze
12
12
 
13
13
  private_constant :CONSTANT_REGEXP
14
14
 
@@ -29,11 +29,11 @@ module Karafka
29
29
 
30
30
  # @return [Karafka::Helpers::MultiDelegator] multi delegator instance
31
31
  # to which we will be writing logs
32
- # We use this approach to log stuff to file and to the STDOUT at the same time
32
+ # We use this approach to log stuff to file and to the $stdout at the same time
33
33
  def target
34
34
  Karafka::Helpers::MultiDelegator
35
35
  .delegate(:write, :close)
36
- .to(STDOUT, file)
36
+ .to($stdout, file)
37
37
  end
38
38
 
39
39
  # Makes sure the log directory exists as long as we can write to it
@@ -16,6 +16,7 @@ module Karafka
16
16
  private_constant :CONTRACT
17
17
 
18
18
  def initialize
19
+ super
19
20
  @draws = Concurrent::Array.new
20
21
  end
21
22
 
@@ -8,9 +8,11 @@ module Karafka
8
8
  class ConsumerGroup
9
9
  extend Helpers::ConfigRetriever
10
10
 
11
- attr_reader :topics
12
- attr_reader :id
13
- attr_reader :name
11
+ attr_reader(
12
+ :topics,
13
+ :id,
14
+ :name
15
+ )
14
16
 
15
17
  # @param name [String, Symbol] raw name of this consumer group. Raw means, that it does not
16
18
  # yet have an application client_id namespace, this will be added here by default.
@@ -89,6 +89,9 @@ module Karafka
89
89
  # are stored for further processing. Note, that each item in the queue represents a
90
90
  # response from a single broker
91
91
  setting :fetcher_max_queue_size, 10
92
+ # option assignment_strategy [Object] a strategy determining the assignment of
93
+ # partitions to the consumers.
94
+ setting :assignment_strategy, Karafka::AssignmentStrategies::RoundRobin.new
92
95
  # option max_bytes_per_partition [Integer] the maximum amount of data fetched
93
96
  # from a single partition at a time.
94
97
  setting :max_bytes_per_partition, 1_048_576
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '1.4.0'
6
+ VERSION = '1.4.1'
7
7
  end
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: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -36,7 +36,7 @@ cert_chain:
36
36
  2DND//YJUikn1zwbz1kT70XmHd97B4Eytpln7K+M1u2g1pHVEPW4owD/ammXNpUy
37
37
  nt70FcDD4yxJQ+0YNiHd0N8IcVBM1TMIVctMNQ==
38
38
  -----END CERTIFICATE-----
39
- date: 2020-09-05 00:00:00.000000000 Z
39
+ date: 2020-12-04 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-configurable
@@ -227,6 +227,7 @@ files:
227
227
  - karafka.gemspec
228
228
  - lib/karafka.rb
229
229
  - lib/karafka/app.rb
230
+ - lib/karafka/assignment_strategies/round_robin.rb
230
231
  - lib/karafka/attributes_map.rb
231
232
  - lib/karafka/backends/inline.rb
232
233
  - lib/karafka/base_consumer.rb
@@ -237,6 +238,7 @@ files:
237
238
  - lib/karafka/cli/flow.rb
238
239
  - lib/karafka/cli/info.rb
239
240
  - lib/karafka/cli/install.rb
241
+ - lib/karafka/cli/missingno.rb
240
242
  - lib/karafka/cli/server.rb
241
243
  - lib/karafka/code_reloader.rb
242
244
  - lib/karafka/connection/api_adapter.rb
metadata.gz.sig CHANGED
Binary file