karafka 2.0.0.alpha2 → 2.0.0.alpha3

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: 112496d14f74a8095df2b0b557e294140f422bbc8d6ea93f0709ac3b4ec017ec
4
- data.tar.gz: a049427bd67d7887c0d5a352c724ecc56b156842859e9688068d36e25aeeb05d
3
+ metadata.gz: 4e715fa7f45c40a200fc2d281d765f5d42ac4f03ba6e3f529b86a0adc90bc1af
4
+ data.tar.gz: 50e2083063f1fd77ffc529395550e443c4166aa035c2d87716390059bec6fe32
5
5
  SHA512:
6
- metadata.gz: d549e3c4bd31a2d011d453495ee6c3f3825ece067285834ef1bc5872cbc257f9695ff831eed7370c0668b33f4c297b1c3512fb068fecafdbd1a5d109d305e243
7
- data.tar.gz: 2f7a48f6490e7ccef765c1697bdb54eb8e596246c853f8e30a85a134e50394c78c983b2ad4020d140da0a532aa1633cd425ba3af12a2d1e2f59fc9264288c3fb
6
+ metadata.gz: d225ba3d118716bcf1265e06d3d781aee7a3e9e87edaab791fdf1b240dc1565a0a460a3f99ca5b8687f6e63701ff2fee3d8ffe343dc18c5e1bfdde4af9deb852
7
+ data.tar.gz: 73084d0b5f3678f37b63debdcf944517e0f954bf0a21242caae3c807ced721afd26f5d6bdb864bcf5fe36bb2d098ca3dd167901a1c3ddc61b0ceb00f8a3a2d96
checksums.yaml.gz.sig CHANGED
Binary file
@@ -113,6 +113,7 @@ jobs:
113
113
  - name: Install latest Bundler
114
114
  run: |
115
115
  gem install bundler --no-document
116
+ gem update --system --no-document
116
117
  bundle config set without 'tools benchmarks docs'
117
118
 
118
119
  - name: Bundle install
@@ -124,4 +125,4 @@ jobs:
124
125
  env:
125
126
  KARAFKA_PRO_LICENSE_TOKEN: ${{ secrets.KARAFKA_PRO_LICENSE_TOKEN }}
126
127
  GITHUB_COVERAGE: ${{matrix.coverage}}
127
- run: bundle exec bin/integrations
128
+ run: bin/integrations
data/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # Karafka framework changelog
2
2
 
3
+ ## 2.0.0-alpha3 (2022-03-16)
4
+ - Restore 'app.initialized' state and add notification on it
5
+ - Fix the installation flow for Rails and add integration tests for this scenario
6
+ - Add more integration tests covering some edge cases
7
+
3
8
  ## 2.0.0-alpha2 (2022-02-19)
4
9
  - Require `kafka` keys to be symbols
10
+ - Added ActiveJob Pro adapter
11
+ - Small updates to the license and docs
5
12
 
6
13
  ## 2.0.0-alpha1 (2022-01-30)
7
14
  - Change license to `LGPL-3.0`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (2.0.0.alpha2)
4
+ karafka (2.0.0.alpha3)
5
5
  dry-configurable (~> 0.13)
6
6
  dry-monitor (~> 0.5)
7
7
  dry-validation (~> 1.7)
@@ -71,7 +71,7 @@ GEM
71
71
  activesupport (>= 5.0)
72
72
  i18n (1.10.0)
73
73
  concurrent-ruby (~> 1.0)
74
- mini_portile2 (2.7.1)
74
+ mini_portile2 (2.8.0)
75
75
  minitest (5.15.0)
76
76
  rake (13.0.6)
77
77
  rdkafka (0.11.1)
data/bin/integrations CHANGED
@@ -2,9 +2,15 @@
2
2
 
3
3
  # Runner to run integration specs in parallel
4
4
 
5
+ # Part of integration specs run pristine without bundler.
6
+ # If we would run bundle exec when running this code, bundler would inject its own context
7
+ # into them, messing things up heavily
8
+ raise 'This code needs to be executed WITHOUT bundle exec' if Kernel.const_defined?(:Bundler)
9
+
5
10
  require 'open3'
6
11
  require 'fileutils'
7
12
  require 'pathname'
13
+ require 'tmpdir'
8
14
 
9
15
  ROOT_PATH = Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), '../')))
10
16
 
@@ -38,9 +44,7 @@ class Scenario
38
44
  # @param path [String] path to the scenarios file
39
45
  def initialize(path)
40
46
  @path = path
41
- @stdin, @stdout, @stderr, @wait_thr = Open3.popen3(
42
- "bundle exec ruby -r ./spec/integrations_helper.rb #{path}"
43
- )
47
+ @stdin, @stdout, @stderr, @wait_thr = Open3.popen3(init_and_build_cmd)
44
48
  @started_at = current_time
45
49
  # Last 1024 characters from stdout
46
50
  @stdout_tail = ''
@@ -102,6 +106,35 @@ class Scenario
102
106
 
103
107
  private
104
108
 
109
+ # Sets up a proper environment for a given spec to run and returns the run command
110
+ # @return [String] run command
111
+ def init_and_build_cmd
112
+ scenario_dir = File.dirname(@path)
113
+
114
+ # If there is a Gemfile in a scenario directory, it means it is a pristine spec and we need
115
+ # to run bundle install, etc in order to run it
116
+ if File.exist?(File.join(scenario_dir, 'Gemfile'))
117
+ # We copy the spec into a temp dir, not to pollute the spec location with logs, etc
118
+ temp_dir = Dir.mktmpdir
119
+ file_name = File.basename(@path)
120
+
121
+ FileUtils.cp_r("#{scenario_dir}/.", temp_dir)
122
+
123
+ <<~CMD
124
+ cd #{temp_dir} &&
125
+ KARAFKA_GEM_DIR=#{ROOT_PATH} \
126
+ BUNDLE_AUTO_INSTALL=true \
127
+ PRISTINE_MODE=true \
128
+ bundle exec ruby -r #{ROOT_PATH}/spec/integrations_helper.rb #{file_name}
129
+ CMD
130
+ else
131
+ <<~CMD
132
+ KARAFKA_GEM_DIR=#{ROOT_PATH} \
133
+ bundle exec ruby -r ./spec/integrations_helper.rb #{@path}
134
+ CMD
135
+ end
136
+ end
137
+
105
138
  # @return [Float] current machine time
106
139
  def current_time
107
140
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
@@ -136,10 +169,13 @@ end
136
169
  # Load all the specs
137
170
  specs = Dir[ROOT_PATH.join('spec/integrations/**/*.rb')]
138
171
 
139
- # If filter is provided, apply
140
- specs.delete_if { |name| !name.include?(ARGV[0]) } if ARGV[0]
172
+ # If filters is provided, apply
173
+ # Allows to provide several filters one after another and applies all of them
174
+ ARGV.each do |filter|
175
+ specs.delete_if { |name| !name.include?(filter) }
176
+ end
141
177
 
142
- raise ArgumentError, "No integration specs with filter: #{ARGV[0]}" if specs.empty?
178
+ raise ArgumentError, "No integration specs with filters: #{ARGV.join(', ')}" if specs.empty?
143
179
 
144
180
  # Randomize order
145
181
  seed = (ENV['SEED'] || rand(0..10_000)).to_i
@@ -14,6 +14,7 @@ module Karafka
14
14
  app/consumers
15
15
  config
16
16
  log
17
+ lib
17
18
  ].freeze
18
19
 
19
20
  # Where should we map proper files from templates
@@ -17,6 +17,7 @@ module Karafka
17
17
  # complete list of all the events. Please use the #available_events on fully loaded
18
18
  # Karafka system to determine all of the events you can use.
19
19
  BASE_EVENTS = %w[
20
+ app.initialized
20
21
  app.running
21
22
  app.stopping
22
23
  app.stopped
@@ -38,36 +38,62 @@ if rails
38
38
  end
39
39
  end
40
40
 
41
- initializer 'karafka.configure_rails_initialization' do |app|
42
- # Consumers should autoload by default in the Rails app so they are visible
43
- app.config.autoload_paths += %w[app/consumers]
44
-
41
+ # This lines will make Karafka print to stdout like puma or unicorn when we run karafka
42
+ # server + will support code reloading with each fetched loop. We do it only for karafka
43
+ # based commands as Rails processes and console will have it enabled already
44
+ initializer 'karafka.configure_rails_logger' do
45
45
  # Make Karafka use Rails logger
46
46
  ::Karafka::App.config.logger = Rails.logger
47
47
 
48
- # This lines will make Karafka print to stdout like puma or unicorn when we run karafka
49
- # server + will support code reloading with each fetched loop. We do it only for karafka
50
- # based commands as Rails processes and console will have it enabled already
51
- if Rails.env.development? && ENV.key?('KARAFKA_CLI')
52
- Rails.logger.extend(
53
- ActiveSupport::Logger.broadcast(
54
- ActiveSupport::Logger.new($stdout)
55
- )
48
+ next unless Rails.env.development?
49
+ next unless ENV.key?('KARAFKA_CLI')
50
+
51
+ Rails.logger.extend(
52
+ ActiveSupport::Logger.broadcast(
53
+ ActiveSupport::Logger.new($stdout)
56
54
  )
55
+ )
56
+ end
57
57
 
58
- # We can have many listeners, but it does not matter in which we will reload the code as
59
- # long as all the consumers will be re-created as Rails reload is thread-safe
60
- ::Karafka::App.monitor.subscribe('connection.listener.fetch_loop') do
61
- # Reload code each time there is a change in the code
62
- next unless Rails.application.reloaders.any?(&:updated?)
58
+ initializer 'karafka.configure_rails_auto_load_paths' do |app|
59
+ # Consumers should autoload by default in the Rails app so they are visible
60
+ app.config.autoload_paths += %w[app/consumers]
61
+ end
63
62
 
64
- Rails.application.reloader.reload!
65
- end
63
+ initializer 'karafka.configure_rails_code_reloader' do
64
+ # There are components that won't work with older Rails version, so we check it and
65
+ # provide a failover
66
+ rails6plus = Rails.gem_version >= Gem::Version.new('6.0.0')
67
+
68
+ next unless Rails.env.development?
69
+ next unless ENV.key?('KARAFKA_CLI')
70
+ next unless rails6plus
71
+
72
+ # We can have many listeners, but it does not matter in which we will reload the code
73
+ # as long as all the consumers will be re-created as Rails reload is thread-safe
74
+ ::Karafka::App.monitor.subscribe('connection.listener.fetch_loop') do
75
+ # Reload code each time there is a change in the code
76
+ next unless Rails.application.reloaders.any?(&:updated?)
77
+
78
+ Rails.application.reloader.reload!
66
79
  end
80
+ end
67
81
 
68
- app.reloader.to_prepare do
69
- # Load Karafka bot file, so it can be used in Rails server context
70
- require Rails.root.join(Karafka.boot_file.to_s).to_s
82
+ initializer 'karafka.require_karafka_boot_file' do |app|
83
+ rails6plus = Rails.gem_version >= Gem::Version.new('6.0.0')
84
+
85
+ karafka_boot_file = Rails.root.join(Karafka.boot_file.to_s).to_s
86
+
87
+ if rails6plus
88
+ app.reloader.to_prepare do
89
+ # Load Karafka boot file, so it can be used in Rails server context
90
+ require karafka_boot_file
91
+ end
92
+ else
93
+ # Load Karafka main setup for older Rails versions
94
+ app.config.after_initialize do
95
+ require karafka_boot_file
96
+ end
71
97
  end
72
98
  end
73
99
  end
@@ -118,6 +118,8 @@ module Karafka
118
118
  Licenser.new.verify(config.license)
119
119
 
120
120
  configure_components
121
+
122
+ Karafka::App.initialized!
121
123
  end
122
124
 
123
125
  private
@@ -6,6 +6,7 @@ module Karafka
6
6
  # Available states and their transitions.
7
7
  STATES = {
8
8
  initializing: :initialize!,
9
+ initialized: :initialized!,
9
10
  running: :run!,
10
11
  stopping: :stop!,
11
12
  stopped: :stopped!
@@ -27,7 +27,7 @@ APP_LOADER.eager_load
27
27
 
28
28
  class KarafkaApp < Karafka::App
29
29
  setup do |config|
30
- config.kafka = { 'bootstrap.servers' => '127.0.0.1:9092' }
30
+ config.kafka = { 'bootstrap.servers': '127.0.0.1:9092' }
31
31
  config.client_id = 'example_app'
32
32
  <% if rails? -%>
33
33
  # Recreate consumers with each batch. This will allow Rails code reload to work in the
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '2.0.0.alpha2'
6
+ VERSION = '2.0.0.alpha3'
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.0.0.alpha2
4
+ version: 2.0.0.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -34,7 +34,7 @@ cert_chain:
34
34
  R2P11bWoCtr70BsccVrN8jEhzwXngMyI2gVt750Y+dbTu1KgRqZKp/ECe7ZzPzXj
35
35
  pIy9vHxTANKYVyI4qj8OrFdEM5BQNu8oQpL0iQ==
36
36
  -----END CERTIFICATE-----
37
- date: 2022-02-19 00:00:00.000000000 Z
37
+ date: 2022-03-16 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: dry-configurable
@@ -151,7 +151,6 @@ files:
151
151
  - ".coditsu/ci.yml"
152
152
  - ".console_irbrc"
153
153
  - ".diffend.yml"
154
- - ".github/FUNDING.yml"
155
154
  - ".github/ISSUE_TEMPLATE/bug_report.md"
156
155
  - ".github/ISSUE_TEMPLATE/feature_request.md"
157
156
  - ".github/workflows/ci.yml"
@@ -283,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
282
  - !ruby/object:Gem::Version
284
283
  version: 1.3.1
285
284
  requirements: []
286
- rubygems_version: 3.3.3
285
+ rubygems_version: 3.3.4
287
286
  signing_key:
288
287
  specification_version: 4
289
288
  summary: Ruby based framework for working with Apache Kafka
metadata.gz.sig CHANGED
Binary file
data/.github/FUNDING.yml DELETED
@@ -1,3 +0,0 @@
1
- # These are supported funding model platforms
2
-
3
- open_collective: karafka