karafka 1.4.2 → 1.4.6

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: b67c595b8ce4b5ff1589517547f94c8e1ba4caf51361074949b7bae1c5368bf6
4
- data.tar.gz: 17c507ddf4d2b4cd62eea3df3a1dec0cef5a257054f7d0321e1c71dcba0d400e
3
+ metadata.gz: fc0edb1580179b926b7adaed4901c8483e0cfa1094b8951adecda7105a2fa1ec
4
+ data.tar.gz: 4392bc711588e38fe53c6b6a9966e7226652efd6db8bfc8b48b7f845bd950a28
5
5
  SHA512:
6
- metadata.gz: 818d4d75303eda22f8e923e7ade1c445f0c2e99aebdb7e56511b5fdf38ea39c047f61c0983bc8d38641676be2c2fcc901df9d2bc0d812c3454664dd73ab27b2e
7
- data.tar.gz: 5c10aced279e74af09d42dd3367a1593abf11267cb09099d0d92a3b4e540f19fa3c06bd9e0f61f7025c3fc0774cde9f4902fb929ca9e24aa308f9d72e6a61def
6
+ metadata.gz: 98c768c6cf9fcb1a594488d4a5f40f87f8c676872f2bee13eec0f20fabb060078594420b2028d57f8aa4c64de2517027df83de9242145e40a9df782e9ec329f0
7
+ data.tar.gz: 28d54e29cc197926f6fe9856334e9aad1b3013102ef7a0aec0ea7425e92d798fb3dcaece97ed3c84d89e9e4e9f170946745951ad9fdfc1730572c240fd99cf31
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,6 +1,7 @@
1
1
  name: ci
2
2
 
3
3
  on:
4
+ pull_request:
4
5
  push:
5
6
  schedule:
6
7
  - cron: '0 1 * * *'
@@ -16,7 +17,6 @@ jobs:
16
17
  - '3.0'
17
18
  - '2.7'
18
19
  - '2.6'
19
- - '2.5'
20
20
  include:
21
21
  - ruby: '3.0'
22
22
  coverage: 'true'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.0.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Karafka framework changelog
2
2
 
3
+ ## 1.4.6 (2021-08-05)
4
+ - #700 Fix Ruby 3 compatibility issues in Connection::Client#pause (MmKolodziej)
5
+
6
+ ## 1.4.5 (2021-06-16)
7
+ - Fixup logger checks for non-writeable logfile (ojab)
8
+ - #689 - Update the stdout initialization message for framework initialization
9
+
10
+ ## 1.4.4 (2021-04-19)
11
+ - Remove Ruby 2.5 support and update minimum Ruby requirement to 2.6
12
+ - Remove rake dependency
13
+
14
+ ## 1.4.3 (2021-03-24)
15
+ - Fixes for Ruby 3.0 compatibility
16
+
3
17
  ## 1.4.2 (2021-02-16)
4
18
  - Rescue Errno::EROFS in ensure_dir_exists (unasuke)
5
19
 
data/Gemfile.lock CHANGED
@@ -1,14 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (1.4.2)
4
+ karafka (1.4.6)
5
5
  dry-configurable (~> 0.8)
6
6
  dry-inflector (~> 0.1)
7
7
  dry-monitor (~> 0.3)
8
8
  dry-validation (~> 1.2)
9
9
  envlogic (~> 1.1)
10
10
  irb (~> 1.0)
11
- rake (>= 11.3)
12
11
  ruby-kafka (>= 1.0.0)
13
12
  thor (>= 0.20)
14
13
  waterdrop (~> 1.4.0)
@@ -17,45 +16,43 @@ PATH
17
16
  GEM
18
17
  remote: https://rubygems.org/
19
18
  specs:
20
- activesupport (6.1.3)
19
+ activesupport (6.1.4)
21
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
21
  i18n (>= 1.6, < 2)
23
22
  minitest (>= 5.1)
24
23
  tzinfo (~> 2.0)
25
24
  zeitwerk (~> 2.3)
26
25
  byebug (11.1.3)
27
- concurrent-ruby (1.1.8)
26
+ concurrent-ruby (1.1.9)
28
27
  delivery_boy (1.1.0)
29
28
  king_konf (~> 1.0)
30
29
  ruby-kafka (~> 1.0)
31
30
  diff-lcs (1.4.4)
32
- digest-crc (0.6.3)
31
+ digest-crc (0.6.4)
33
32
  rake (>= 12.0.0, < 14.0.0)
34
- docile (1.3.5)
33
+ docile (1.4.0)
35
34
  dry-configurable (0.12.1)
36
35
  concurrent-ruby (~> 1.0)
37
36
  dry-core (~> 0.5, >= 0.5.0)
38
- dry-container (0.7.2)
37
+ dry-container (0.8.0)
39
38
  concurrent-ruby (~> 1.0)
40
39
  dry-configurable (~> 0.1, >= 0.1.3)
41
- dry-core (0.5.0)
40
+ dry-core (0.7.1)
42
41
  concurrent-ruby (~> 1.0)
43
42
  dry-equalizer (0.3.0)
44
- dry-events (0.2.0)
43
+ dry-events (0.3.0)
45
44
  concurrent-ruby (~> 1.0)
46
- dry-core (~> 0.4)
47
- dry-equalizer (~> 0.2)
48
- dry-inflector (0.2.0)
45
+ dry-core (~> 0.5, >= 0.5)
46
+ dry-inflector (0.2.1)
49
47
  dry-initializer (3.0.4)
50
- dry-logic (1.1.0)
48
+ dry-logic (1.2.0)
51
49
  concurrent-ruby (~> 1.0)
52
50
  dry-core (~> 0.5, >= 0.5)
53
- dry-monitor (0.3.2)
51
+ dry-monitor (0.4.0)
54
52
  dry-configurable (~> 0.5)
55
- dry-core (~> 0.4)
56
- dry-equalizer (~> 0.2)
53
+ dry-core (~> 0.5, >= 0.5)
57
54
  dry-events (~> 0.2)
58
- dry-schema (1.6.1)
55
+ dry-schema (1.7.0)
59
56
  concurrent-ruby (~> 1.0)
60
57
  dry-configurable (~> 0.8, >= 0.8.3)
61
58
  dry-core (~> 0.5, >= 0.5)
@@ -75,19 +72,19 @@ GEM
75
72
  dry-equalizer (~> 0.2)
76
73
  dry-initializer (~> 3.0)
77
74
  dry-schema (~> 1.5, >= 1.5.2)
78
- envlogic (1.1.2)
75
+ envlogic (1.1.3)
79
76
  dry-inflector (~> 0.1)
80
- factory_bot (6.1.0)
77
+ factory_bot (6.2.0)
81
78
  activesupport (>= 5.0.0)
82
- i18n (1.8.9)
79
+ i18n (1.8.10)
83
80
  concurrent-ruby (~> 1.0)
84
- io-console (0.5.8)
85
- irb (1.3.4)
86
- reline (>= 0.1.5)
81
+ io-console (0.5.9)
82
+ irb (1.3.6)
83
+ reline (>= 0.2.5)
87
84
  king_konf (1.0.0)
88
- minitest (5.14.3)
89
- rake (13.0.3)
90
- reline (0.2.4)
85
+ minitest (5.14.4)
86
+ rake (13.0.6)
87
+ reline (0.2.6)
91
88
  io-console (~> 0.5)
92
89
  rspec (3.10.0)
93
90
  rspec-core (~> 3.10.0)
@@ -109,11 +106,11 @@ GEM
109
106
  simplecov-html (~> 0.11)
110
107
  simplecov_json_formatter (~> 0.1)
111
108
  simplecov-html (0.12.3)
112
- simplecov_json_formatter (0.1.2)
109
+ simplecov_json_formatter (0.1.3)
113
110
  thor (1.1.0)
114
111
  tzinfo (2.0.4)
115
112
  concurrent-ruby (~> 1.0)
116
- waterdrop (1.4.0)
113
+ waterdrop (1.4.2)
117
114
  delivery_boy (>= 0.2, < 2.x)
118
115
  dry-configurable (~> 0.8)
119
116
  dry-monitor (~> 0.3)
@@ -123,8 +120,7 @@ GEM
123
120
  zeitwerk (2.4.2)
124
121
 
125
122
  PLATFORMS
126
- ruby
127
- x86_64-darwin-19
123
+ x86_64-linux
128
124
 
129
125
  DEPENDENCIES
130
126
  byebug
@@ -134,4 +130,4 @@ DEPENDENCIES
134
130
  simplecov
135
131
 
136
132
  BUNDLED WITH
137
- 2.2.11
133
+ 2.2.24
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ![karafka logo](https://raw.githubusercontent.com/karafka/misc/master/logo/karafka_logotype_transparent2.png)
2
2
 
3
- [![Build Status](https://travis-ci.org/karafka/karafka.svg?branch=master)](https://travis-ci.org/karafka/karafka)
3
+ [![Build Status](https://github.com/karafka/karafka/actions/workflows/ci.yml/badge.svg)](https://github.com/karafka/karafka/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/karafka.svg)](http://badge.fury.io/rb/karafka)
5
+ [![Join the chat at https://gitter.im/karafka/karafka](https://badges.gitter.im/karafka/karafka.svg)](https://gitter.im/karafka/karafka)
4
6
 
5
- **Note**: Documentation presented here refers to Karafka `1.4`.
6
-
7
- If you are looking for the documentation for Karafka `1.3.x`, it can be found [here](https://github.com/karafka/wiki/tree/1.3).
7
+ **Note**: We're finishing the new Karafka `2.0` but for now, please use `1.4`. All the documentation presented here refers to `1.4`
8
8
 
9
9
  ## About Karafka
10
10
 
@@ -72,7 +72,7 @@ Karafka framework and Karafka team are __not__ related to Kafka streaming servic
72
72
  ## References
73
73
 
74
74
  * [Karafka framework](https://github.com/karafka/karafka)
75
- * [Karafka Travis CI](https://travis-ci.org/karafka/karafka)
75
+ * [Karafka GitHub Actions](https://github.com/karafka/karafka/actions)
76
76
  * [Karafka Coditsu](https://app.coditsu.io/karafka/repositories/karafka)
77
77
 
78
78
  ## Note on contributions
data/karafka.gemspec CHANGED
@@ -23,13 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'dry-validation', '~> 1.2'
24
24
  spec.add_dependency 'envlogic', '~> 1.1'
25
25
  spec.add_dependency 'irb', '~> 1.0'
26
- spec.add_dependency 'rake', '>= 11.3'
27
26
  spec.add_dependency 'ruby-kafka', '>= 1.0.0'
28
27
  spec.add_dependency 'thor', '>= 0.20'
29
28
  spec.add_dependency 'waterdrop', '~> 1.4.0'
30
29
  spec.add_dependency 'zeitwerk', '~> 2.1'
31
30
 
32
- spec.required_ruby_version = '>= 2.5.0'
31
+ spec.required_ruby_version = '>= 2.6.0'
33
32
 
34
33
  if $PROGRAM_NAME.end_with?('gem')
35
34
  spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
@@ -34,7 +34,7 @@ module Karafka
34
34
  Bundler.read_file(
35
35
  Bundler.default_lockfile
36
36
  )
37
- ).dependencies.key?('rails')
37
+ ).dependencies.key?('railties')
38
38
  end
39
39
 
40
40
  # Install all required things for Karafka application in current directory
@@ -31,14 +31,6 @@ module Karafka
31
31
  # part of the topics
32
32
  Karafka::Server.consumer_groups = cli.options[:consumer_groups]
33
33
 
34
- # Remove pidfile on stop, just before the server instance is going to be GCed
35
- # We want to delay the moment in which the pidfile is removed as much as we can,
36
- # so instead of removing it after the server stops running, we rely on the gc moment
37
- # when this object gets removed (it is a bit later), so it is closer to the actual
38
- # system process end. We do that, so monitoring and deployment tools that rely on a pid
39
- # won't alarm or start new system process up until the current one is finished
40
- ObjectSpace.define_finalizer(self, proc { send(:clean) })
41
-
42
34
  Karafka::Server.run
43
35
  end
44
36
 
@@ -60,6 +52,14 @@ module Karafka
60
52
  cli.options[:pid],
61
53
  'w'
62
54
  ) { |file| file.write(::Process.pid) }
55
+
56
+ # Remove pidfile on stop, just before the server instance is going to be GCed
57
+ # We want to delay the moment in which the pidfile is removed as much as we can,
58
+ # so instead of removing it after the server stops running, we rely on the gc moment
59
+ # when this object gets removed (it is a bit later), so it is closer to the actual
60
+ # system process end. We do that, so monitoring and deployment tools that rely on a pid
61
+ # won't alarm or start new system process up until the current one is finished
62
+ ObjectSpace.define_finalizer(self, proc { send(:clean) })
63
63
  end
64
64
 
65
65
  # Removes a pidfile (if exist)
@@ -48,30 +48,28 @@ module Karafka
48
48
 
49
49
  # Builds all the configuration settings for kafka#consumer method
50
50
  # @param consumer_group [Karafka::Routing::ConsumerGroup] consumer group details
51
- # @return [Array<Hash>] array with all the consumer arguments including hash with all
51
+ # @return [Hash] all the consumer keyword arguments including hash with all
52
52
  # the settings required by Kafka#consumer
53
53
  def consumer(consumer_group)
54
54
  settings = { group_id: consumer_group.id }
55
55
  settings = fetch_for(:consumer, consumer_group, settings)
56
- [sanitize(settings)]
56
+ sanitize(settings)
57
57
  end
58
58
 
59
59
  # Builds all the configuration settings for kafka consumer consume_each_batch and
60
60
  # consume_each_message methods
61
61
  # @param consumer_group [Karafka::Routing::ConsumerGroup] consumer group details
62
- # @return [Array<Hash>] Array with all the arguments required by consuming method
63
- # including hash with all the settings required by
62
+ # @return [Hash] hash with all the arguments required by consuming method
63
+ # including all the settings required by
64
64
  # Kafka::Consumer#consume_each_message and Kafka::Consumer#consume_each_batch method
65
65
  def consumption(consumer_group)
66
- [
67
- sanitize(
68
- fetch_for(
69
- :consumption,
70
- consumer_group,
71
- automatically_mark_as_processed: consumer_group.automatically_mark_as_consumed
72
- )
66
+ sanitize(
67
+ fetch_for(
68
+ :consumption,
69
+ consumer_group,
70
+ automatically_mark_as_processed: consumer_group.automatically_mark_as_consumed
73
71
  )
74
- ]
72
+ )
75
73
  end
76
74
 
77
75
  # Builds all the configuration settings for kafka consumer#subscribe method
@@ -86,17 +84,16 @@ module Karafka
86
84
  # @param topic [String] topic that we want to pause
87
85
  # @param partition [Integer] number partition that we want to pause
88
86
  # @param consumer_group [Karafka::Routing::ConsumerGroup] consumer group details
89
- # @return [Array] array with all the details required to pause kafka consumer
87
+ # @return [Hash] hash with all the details required to pause kafka consumer
90
88
  def pause(topic, partition, consumer_group)
91
- [
92
- Karafka::App.config.topic_mapper.outgoing(topic),
93
- partition,
94
- {
89
+ {
90
+ args: [Karafka::App.config.topic_mapper.outgoing(topic), partition],
91
+ kwargs: {
95
92
  timeout: consumer_group.pause_timeout,
96
93
  max_timeout: consumer_group.pause_max_timeout,
97
94
  exponential_backoff: consumer_group.pause_exponential_backoff
98
95
  }
99
- ]
96
+ }
100
97
  end
101
98
 
102
99
  # Remaps topic details taking the topic mapper feature into consideration.
@@ -10,7 +10,12 @@ module Karafka
10
10
  # to have a new Kafka client
11
11
  # @return [::Kafka::Client] returns a Kafka client
12
12
  def call(consumer_group)
13
- Kafka.new(*ApiAdapter.client(consumer_group))
13
+ settings = ApiAdapter.client(consumer_group)
14
+
15
+ Kafka.new(
16
+ settings[0],
17
+ **settings[1]
18
+ )
14
19
  end
15
20
  end
16
21
  end
@@ -33,9 +33,9 @@ module Karafka
33
33
  settings = ApiAdapter.consumption(consumer_group)
34
34
 
35
35
  if consumer_group.batch_fetching
36
- kafka_consumer.each_batch(*settings) { |batch| yield(batch, :batch) }
36
+ kafka_consumer.each_batch(**settings) { |batch| yield(batch, :batch) }
37
37
  else
38
- kafka_consumer.each_message(*settings) { |message| yield(message, :message) }
38
+ kafka_consumer.each_message(**settings) { |message| yield(message, :message) }
39
39
  end
40
40
  # @note We catch only the processing errors as any other are considered critical (exceptions)
41
41
  # and should require a client restart with a backoff
@@ -64,7 +64,8 @@ module Karafka
64
64
  # @param topic [String] topic that we want to pause
65
65
  # @param partition [Integer] number partition that we want to pause
66
66
  def pause(topic, partition)
67
- kafka_consumer.pause(*ApiAdapter.pause(topic, partition, consumer_group))
67
+ args, kwargs = ApiAdapter.pause(topic, partition, consumer_group).values_at(:args, :kwargs)
68
+ kafka_consumer.pause(*args, **kwargs)
68
69
  end
69
70
 
70
71
  # Marks given message as consumed
@@ -98,10 +99,12 @@ module Karafka
98
99
  # @note We don't cache the connection internally because we cache kafka_consumer that uses
99
100
  # kafka client object instance
100
101
  @kafka_consumer ||= Builder.call(consumer_group).consumer(
101
- *ApiAdapter.consumer(consumer_group)
102
+ **ApiAdapter.consumer(consumer_group)
102
103
  ).tap do |consumer|
103
104
  consumer_group.topics.each do |topic|
104
- consumer.subscribe(*ApiAdapter.subscribe(topic))
105
+ settings = ApiAdapter.subscribe(topic)
106
+
107
+ consumer.subscribe(settings[0], **settings[1])
105
108
  end
106
109
  end
107
110
  rescue Kafka::ConnectionError
@@ -20,7 +20,6 @@ module Karafka
20
20
  # @param _args Any arguments that we don't care about but that are needed in order to
21
21
  # make this logger compatible with the default Ruby one
22
22
  def initialize(*_args)
23
- ensure_dir_exists
24
23
  super(target)
25
24
  self.level = ENV_MAP[Karafka.env] || ENV_MAP['default']
26
25
  end
@@ -33,14 +32,7 @@ module Karafka
33
32
  def target
34
33
  Karafka::Helpers::MultiDelegator
35
34
  .delegate(:write, :close)
36
- .to($stdout, file)
37
- end
38
-
39
- # Makes sure the log directory exists as long as we can write to it
40
- def ensure_dir_exists
41
- FileUtils.mkdir_p(File.dirname(log_path))
42
- rescue Errno::EACCES, Errno::EROFS
43
- nil
35
+ .to(*[$stdout, file].compact)
44
36
  end
45
37
 
46
38
  # @return [Pathname] Path to a file to which we should log
@@ -51,7 +43,11 @@ module Karafka
51
43
  # @return [File] file to which we want to write our logs
52
44
  # @note File is being opened in append mode ('a')
53
45
  def file
46
+ FileUtils.mkdir_p(File.dirname(log_path))
47
+
54
48
  @file ||= File.open(log_path, 'a')
49
+ rescue Errno::EACCES, Errno::EROFS
50
+ nil
55
51
  end
56
52
  end
57
53
  end
@@ -103,10 +103,10 @@ module Karafka
103
103
  info "Responded from #{calling.class} using #{responder} with following data #{data}"
104
104
  end
105
105
 
106
- # Logs info that we're initializing Karafka app
106
+ # Logs info that we're initializing Karafka framework components
107
107
  # @param _event [Dry::Events::Event] event details including payload
108
108
  def on_app_initializing(_event)
109
- info "Initializing Karafka server #{::Process.pid}"
109
+ info "Initializing Karafka framework #{::Process.pid}"
110
110
  end
111
111
 
112
112
  # Logs info that we're running Karafka app
@@ -58,7 +58,7 @@ module Karafka
58
58
  def stop_supervised
59
59
  Karafka::App.stop!
60
60
 
61
- # Temporary patch until https://github.com/dry-rb/dry-configurable/issues/93 is fixed
61
+ # See https://github.com/dry-rb/dry-configurable/issues/93
62
62
  timeout = Thread.new { Karafka::App.config.shutdown_timeout }.join.value
63
63
 
64
64
  # We check from time to time (for the timeout period) if all the threads finished
@@ -54,7 +54,7 @@ class KarafkaApp < Karafka::App
54
54
  # listen to only what you really need for given environment.
55
55
  Karafka.monitor.subscribe(WaterDrop::Instrumentation::StdoutListener.new)
56
56
  Karafka.monitor.subscribe(Karafka::Instrumentation::StdoutListener.new)
57
- Karafka.monitor.subscribe(Karafka::Instrumentation::ProctitleListener.new)
57
+ # Karafka.monitor.subscribe(Karafka::Instrumentation::ProctitleListener.new)
58
58
 
59
59
  # Uncomment that in order to achieve code reload in development mode
60
60
  # Be aware, that this might have some side-effects. Please refer to the wiki
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '1.4.2'
6
+ VERSION = '1.4.6'
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.2
4
+ version: 1.4.6
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: 2021-02-26 00:00:00.000000000 Z
39
+ date: 2021-08-05 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-configurable
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.0'
125
- - !ruby/object:Gem::Dependency
126
- name: rake
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '11.3'
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '11.3'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: ruby-kafka
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -313,14 +299,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
313
299
  requirements:
314
300
  - - ">="
315
301
  - !ruby/object:Gem::Version
316
- version: 2.5.0
302
+ version: 2.6.0
317
303
  required_rubygems_version: !ruby/object:Gem::Requirement
318
304
  requirements:
319
305
  - - ">="
320
306
  - !ruby/object:Gem::Version
321
307
  version: '0'
322
308
  requirements: []
323
- rubygems_version: 3.2.3
309
+ rubygems_version: 3.2.25
324
310
  signing_key:
325
311
  specification_version: 4
326
312
  summary: Ruby based framework for working with Apache Kafka
metadata.gz.sig CHANGED
Binary file