karafka 2.0.0.rc6 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/ci.yml +0 -8
- data/CHANGELOG.md +95 -2
- data/Gemfile.lock +1 -1
- data/README.md +1 -3
- data/docker-compose.yml +1 -30
- data/lib/karafka/admin.rb +57 -0
- data/lib/karafka/instrumentation/notifications.rb +1 -0
- data/lib/karafka/processing/worker.rb +5 -1
- data/lib/karafka/railtie.rb +10 -0
- data/lib/karafka/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +5 -5
- metadata.gz.sig +0 -0
- data/bin/wait_for_kafka +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2b67a18484b250b65788db213f615b7f1304ab33d6645bceeebdf8025b54bda
|
4
|
+
data.tar.gz: 27d4ece68701b9f34266ff834c9d0809690e06b108412f68916a39880a7a23f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 682a0ff35d78e9eb5590bdb32bbc14bf47f18029003286d55d1f6f14425cd3d3ad6e8081a574f3f2146bc95d9ac692e9dc82622065e6dc6f092dc3dbe61652f3
|
7
|
+
data.tar.gz: 5a4e68ea639b9261172c055e6f22a741735262eb277acd18e465c862ead0242d0287b8872d6add290af0bba681f000a328f4c16d1ee31ca9075fe880552ddf9b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.github/workflows/ci.yml
CHANGED
@@ -73,10 +73,6 @@ jobs:
|
|
73
73
|
ruby-version: ${{matrix.ruby}}
|
74
74
|
bundler-cache: true
|
75
75
|
|
76
|
-
- name: Ensure all needed Kafka topics are created and wait if not
|
77
|
-
run: |
|
78
|
-
bin/wait_for_kafka
|
79
|
-
|
80
76
|
- name: Run all specs
|
81
77
|
env:
|
82
78
|
GITHUB_COVERAGE: ${{matrix.coverage}}
|
@@ -120,10 +116,6 @@ jobs:
|
|
120
116
|
bundle config set without development
|
121
117
|
bundle install
|
122
118
|
|
123
|
-
- name: Ensure all needed Kafka topics are created and wait if not
|
124
|
-
run: |
|
125
|
-
bin/wait_for_kafka
|
126
|
-
|
127
119
|
- name: Run integration tests
|
128
120
|
env:
|
129
121
|
KARAFKA_PRO_LICENSE_TOKEN: ${{ secrets.KARAFKA_PRO_LICENSE_TOKEN }}
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,100 @@
|
|
1
1
|
# Karafka framework changelog
|
2
2
|
|
3
|
+
## 2.0.2 (2022-08-07)
|
4
|
+
- Bypass issue with Rails reload in development by releasing the connection (https://github.com/rails/rails/issues/44183).
|
5
|
+
|
6
|
+
## 2.0.1 (2022-08-06)
|
7
|
+
- Provide `Karafka::Admin` for creation and destruction of topics and fetching cluster info.
|
8
|
+
- Update integration specs to always use one-time disposable topics.
|
9
|
+
- Remove no longer needed `wait_for_kafka` script.
|
10
|
+
- Add more integration specs for cover offset management upon errors.
|
11
|
+
|
12
|
+
## 2.0.0 (2022-08-05)
|
13
|
+
|
14
|
+
This changelog describes changes between `1.4` and `2.0`. Please refer to appropriate release notes for changes between particular `rc` releases.
|
15
|
+
|
16
|
+
Karafka 2.0 is a **major** rewrite that brings many new things to the table but also removes specific concepts that happened not to be as good as I initially thought when I created them.
|
17
|
+
|
18
|
+
Please consider getting a Pro version if you want to **support** my work on the Karafka ecosystem!
|
19
|
+
|
20
|
+
For anyone worried that I will start converting regular features into Pro: This will **not** happen. Anything free and fully OSS in Karafka 1.4 will **forever** remain free. Most additions and improvements to the ecosystem are to its free parts. Any feature that is introduced as a free and open one will not become paid.
|
21
|
+
|
22
|
+
### Additions
|
23
|
+
|
24
|
+
This section describes **new** things and concepts introduced with Karafka 2.0.
|
25
|
+
|
26
|
+
Karafka 2.0:
|
27
|
+
|
28
|
+
- Introduces multi-threaded support for [concurrent work](https://github.com/karafka/karafka/wiki/Concurrency-and-multithreading) consumption for separate partitions as well as for single partition work via [Virtual Partitions](https://github.com/karafka/karafka/wiki/Pro-Virtual-Partitions).
|
29
|
+
- Introduces [Active Job adapter](https://github.com/karafka/karafka/wiki/Active-Job) for using Karafka as a jobs backend with Ruby on Rails Active Job.
|
30
|
+
- Introduces fully automatic integration end-to-end [test suite](https://github.com/karafka/karafka/tree/master/spec/integrations) that checks any case I could imagine.
|
31
|
+
- Introduces [Virtual Partitions](https://github.com/karafka/karafka/wiki/Pro-Virtual-Partitions) for ability to parallelize work of a single partition.
|
32
|
+
- Introduces [Long-Running Jobs](https://github.com/karafka/karafka/wiki/Pro-Long-Running-Jobs) to allow for work that would otherwise exceed the `max.poll.interval.ms`.
|
33
|
+
- Introduces the [Enhanced Scheduler](https://github.com/karafka/karafka/wiki/Pro-Enhanced-Scheduler) that uses a non-preemptive LJF (Longest Job First) algorithm instead of a a FIFO (First-In, First-Out) one.
|
34
|
+
- Introduces [Enhanced Active Job adapter](https://github.com/karafka/karafka/wiki/Pro-Enhanced-Active-Job) that is optimized and allows for strong ordering of jobs and more.
|
35
|
+
- Introduces seamless [Ruby on Rails integration](https://github.com/karafka/karafka/wiki/Integrating-with-Ruby-on-Rails-and-other-frameworks) via `Rails::Railte` without need for any extra configuration.
|
36
|
+
- Provides `#revoked` [method](https://github.com/karafka/karafka/wiki/Consuming-messages#shutdown-and-partition-revocation-handlers) for taking actions upon topic revocation.
|
37
|
+
- Emits underlying async errors emitted from `librdkafka` via the standardized `error.occurred` [monitor channel](https://github.com/karafka/karafka/wiki/Error-handling-and-back-off-policy#error-tracking).
|
38
|
+
- Replaces `ruby-kafka` with `librdkafka` as an underlying driver.
|
39
|
+
- Introduces official [EOL policies](https://github.com/karafka/karafka/wiki/Versions-Lifecycle-and-EOL).
|
40
|
+
- Introduces [benchmarks](https://github.com/karafka/karafka/tree/master/spec/benchmarks) that can be used to profile Karafka.
|
41
|
+
- Introduces a requirement that the end user code **needs** to be [thread-safe](https://github.com/karafka/karafka/wiki/FAQ#does-karafka-require-gems-to-be-thread-safe).
|
42
|
+
- Introduces a [Pro subscription](https://github.com/karafka/karafka/wiki/Build-vs.-Buy) with a [commercial license](https://github.com/karafka/karafka/blob/master/LICENSE-COMM) to fund further ecosystem development.
|
43
|
+
|
44
|
+
### Deletions
|
45
|
+
|
46
|
+
This section describes things that are **no longer** part of the Karafka ecosystem.
|
47
|
+
|
48
|
+
Karafka 2.0:
|
49
|
+
|
50
|
+
- Removes topics mappers concept completely.
|
51
|
+
- Removes pidfiles support.
|
52
|
+
- Removes daemonization support.
|
53
|
+
- Removes support for using `sidekiq-backend` due to introduction of [multi-threading](https://github.com/karafka/karafka/wiki/Concurrency-and-multithreading).
|
54
|
+
- Removes the `Responders` concept in favour of WaterDrop producer usage.
|
55
|
+
- Removes completely all the callbacks in favour of finalizer method `#shutdown`.
|
56
|
+
- Removes single message consumption mode in favour of [documentation](https://github.com/karafka/karafka/wiki/Consuming-messages#one-at-a-time) on how to do it easily by yourself.
|
57
|
+
|
58
|
+
### Changes
|
59
|
+
|
60
|
+
This section describes things that were **changed** in Karafka but are still present.
|
61
|
+
|
62
|
+
Karafka 2.0:
|
63
|
+
|
64
|
+
- Uses only instrumentation that comes from Karafka. This applies also to notifications coming natively from `librdkafka`. They are now piped through Karafka prior to being dispatched.
|
65
|
+
- Integrates WaterDrop `2.x` tightly with autoconfiguration inheritance and an option to redefine it.
|
66
|
+
- Integrates with the `karafka-testing` gem for RSpec that also has been updated.
|
67
|
+
- Updates `cli info` to reflect the `2.0` details.
|
68
|
+
- Stops validating `kafka` configuration beyond minimum as the rest is handled by `librdkafka`.
|
69
|
+
- No longer uses `dry-validation`.
|
70
|
+
- No longer uses `dry-monitor`.
|
71
|
+
- No longer uses `dry-configurable`.
|
72
|
+
- Lowers general external dependencies three **heavily**.
|
73
|
+
- Renames `Karafka::Params::BatchMetadata` to `Karafka::Messages::BatchMetadata`.
|
74
|
+
- Renames `Karafka::Params::Params` to `Karafka::Messages::Message`.
|
75
|
+
- Renames `#params_batch` in consumers to `#messages`.
|
76
|
+
- Renames `Karafka::Params::Metadata` to `Karafka::Messages::Metadata`.
|
77
|
+
- Renames `Karafka::Fetcher` to `Karafka::Runner` and align notifications key names.
|
78
|
+
- Renames `StdoutListener` to `LoggerListener`.
|
79
|
+
- Reorganizes [monitoring and logging](https://github.com/karafka/karafka/wiki/Monitoring-and-logging) to match new concepts.
|
80
|
+
- Notifies on fatal worker processing errors.
|
81
|
+
- Contains updated install templates for Rails and no-non Rails.
|
82
|
+
- Changes how the routing style (`0.5`) behaves. It now builds a single consumer group instead of one per topic.
|
83
|
+
- Introduces changes that will allow me to build full web-UI in the upcoming `2.1`.
|
84
|
+
- Contains updated example apps.
|
85
|
+
- Standardizes error hooks for all error reporting (`error.occurred`).
|
86
|
+
- Changes license to `LGPL-3.0`.
|
87
|
+
- Introduces a `karafka-core` dependency that contains common code used across the ecosystem.
|
88
|
+
- Contains updated [wiki](https://github.com/karafka/karafka/wiki) on everything I could think of.
|
89
|
+
|
90
|
+
### What's ahead
|
91
|
+
|
92
|
+
Karafka 2.0 is just the beginning.
|
93
|
+
|
94
|
+
There are several things in the plan already for 2.1 and beyond, including a web dashboard, at-rest encryption, transactions support, and more.
|
95
|
+
|
3
96
|
## 2.0.0.rc6 (2022-08-05)
|
4
|
-
- Update licenser to use a gem based approach based on `karafka
|
97
|
+
- Update licenser to use a gem based approach based on `karafka-license`.
|
5
98
|
- Do not mark intermediate jobs as consumed when Karafka runs Enhanced Active Job with Virtual Partitions.
|
6
99
|
- Improve development experience by adding fast cluster state changes refresh (#944)
|
7
100
|
- Improve the license loading.
|
@@ -59,7 +152,7 @@
|
|
59
152
|
- Add more integration specs related to polling limits.
|
60
153
|
- Remove auto-detection of re-assigned partitions upon rebalance as for too fast rebalances it could not be accurate enough. It would also mess up in case of rebalances that would happen right after a `#seek` was issued for a partition.
|
61
154
|
- Optimize the removal of pre-buffered lost partitions data.
|
62
|
-
- Always
|
155
|
+
- Always run `#revoked` when rebalance with revocation happens.
|
63
156
|
- Evict executors upon rebalance, to prevent race-conditions.
|
64
157
|
- Align topics names for integration specs.
|
65
158
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,8 +4,6 @@
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/karafka.svg)](http://badge.fury.io/rb/karafka)
|
5
5
|
[![Join the chat at https://slack.karafka.io](https://raw.githubusercontent.com/karafka/misc/master/slack.svg)](https://slack.karafka.io)
|
6
6
|
|
7
|
-
**Note**: All of the documentation here refers to Karafka `2.0.0.rc5` or higher. If you are looking for the documentation for Karafka `1.4`, please click [here](https://github.com/karafka/wiki/tree/1.4).
|
8
|
-
|
9
7
|
## About Karafka
|
10
8
|
|
11
9
|
Karafka is a Ruby and Rails multi-threaded efficient Kafka processing framework that:
|
@@ -55,7 +53,7 @@ We also maintain many [integration specs](https://github.com/karafka/karafka/tre
|
|
55
53
|
1. Add and install Karafka:
|
56
54
|
|
57
55
|
```bash
|
58
|
-
bundle add karafka
|
56
|
+
bundle add karafka
|
59
57
|
|
60
58
|
bundle exec karafka install
|
61
59
|
```
|
data/docker-compose.yml
CHANGED
@@ -16,36 +16,7 @@ services:
|
|
16
16
|
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
17
17
|
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
|
18
18
|
KAFKA_CREATE_TOPICS:
|
19
|
-
"
|
20
|
-
integrations_01_02:2:1,\
|
21
|
-
integrations_02_02:2:1,\
|
22
|
-
integrations_03_02:2:1,\
|
23
|
-
integrations_04_02:2:1,\
|
24
|
-
integrations_05_02:2:1,\
|
25
|
-
integrations_06_02:2:1,\
|
26
|
-
integrations_07_02:2:1,\
|
27
|
-
integrations_08_02:2:1,\
|
28
|
-
integrations_09_02:2:1,\
|
29
|
-
integrations_10_02:2:1,\
|
30
|
-
integrations_11_02:2:1,\
|
31
|
-
integrations_12_02:2:1,\
|
32
|
-
integrations_13_02:2:1,\
|
33
|
-
integrations_14_02:2:1,\
|
34
|
-
integrations_15_02:2:1,\
|
35
|
-
integrations_16_02:2:1,\
|
36
|
-
integrations_17_02:2:1,\
|
37
|
-
integrations_18_02:2:1,\
|
38
|
-
integrations_19_02:2:1,\
|
39
|
-
integrations_20_02:2:1,\
|
40
|
-
integrations_21_02:2:1,\
|
41
|
-
integrations_00_03:3:1,\
|
42
|
-
integrations_01_03:3:1,\
|
43
|
-
integrations_02_03:3:1,\
|
44
|
-
integrations_03_03:3:1,\
|
45
|
-
integrations_04_03:3:1,\
|
46
|
-
integrations_00_10:10:1,\
|
47
|
-
integrations_01_10:10:1,\
|
48
|
-
benchmarks_00_01:1:1,\
|
19
|
+
"benchmarks_00_01:1:1,\
|
49
20
|
benchmarks_00_05:5:1,\
|
50
21
|
benchmarks_01_05:5:1,\
|
51
22
|
benchmarks_00_10:10:1"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
# Simple admin actions that we can perform via Karafka on our Kafka cluster
|
5
|
+
#
|
6
|
+
# @note It always initializes a new admin instance as we want to ensure it is always closed
|
7
|
+
# Since admin actions are not performed that often, that should be ok.
|
8
|
+
#
|
9
|
+
# @note It always uses the primary defined cluster and does not support multi-cluster work.
|
10
|
+
# If you need this, just replace the cluster info for the time you use this
|
11
|
+
module Admin
|
12
|
+
class << self
|
13
|
+
# Creates Kafka topic with given settings
|
14
|
+
#
|
15
|
+
# @param name [String] topic name
|
16
|
+
# @param partitions [Integer] number of partitions we expect
|
17
|
+
# @param replication_factor [Integer] number of replicas
|
18
|
+
# @param topic_config [Hash] topic config details as described here:
|
19
|
+
# https://kafka.apache.org/documentation/#topicconfigs
|
20
|
+
def create_topic(name, partitions, replication_factor, topic_config = {})
|
21
|
+
with_admin do |admin|
|
22
|
+
admin
|
23
|
+
.create_topic(name, partitions, replication_factor, topic_config)
|
24
|
+
.wait
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Deleted a given topic
|
29
|
+
#
|
30
|
+
# @param name [String] topic name
|
31
|
+
def delete_topic(name)
|
32
|
+
with_admin do |admin|
|
33
|
+
admin
|
34
|
+
.delete_topic(name)
|
35
|
+
.wait
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Rdkafka::Metadata] cluster metadata info
|
40
|
+
def cluster_info
|
41
|
+
with_admin do |admin|
|
42
|
+
Rdkafka::Metadata.new(admin.instance_variable_get('@native_kafka'))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# Creates admin instance and yields it. After usage it closes the admin instance
|
49
|
+
def with_admin
|
50
|
+
admin = ::Rdkafka::Config.new(Karafka::App.config.kafka).admin
|
51
|
+
result = yield(admin)
|
52
|
+
admin.close
|
53
|
+
result
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -46,8 +46,9 @@ module Karafka
|
|
46
46
|
def process
|
47
47
|
job = @jobs_queue.pop
|
48
48
|
|
49
|
+
instrument_details = { caller: self, job: job, jobs_queue: @jobs_queue }
|
50
|
+
|
49
51
|
if job
|
50
|
-
instrument_details = { caller: self, job: job, jobs_queue: @jobs_queue }
|
51
52
|
|
52
53
|
Karafka.monitor.instrument('worker.process', instrument_details)
|
53
54
|
|
@@ -82,6 +83,9 @@ module Karafka
|
|
82
83
|
ensure
|
83
84
|
# job can be nil when the queue is being closed
|
84
85
|
@jobs_queue.complete(job) if job
|
86
|
+
|
87
|
+
# Always publish info, that we completed all the work despite its result
|
88
|
+
Karafka.monitor.instrument('worker.completed', instrument_details)
|
85
89
|
end
|
86
90
|
end
|
87
91
|
end
|
data/lib/karafka/railtie.rb
CHANGED
@@ -77,6 +77,16 @@ if rails
|
|
77
77
|
|
78
78
|
Rails.application.reloader.reload!
|
79
79
|
end
|
80
|
+
|
81
|
+
::Karafka::App.monitor.subscribe('worker.completed') do
|
82
|
+
# Skip in case someone is using Rails without ActiveRecord
|
83
|
+
next unless Object.const_defined?('ActiveRecord::Base')
|
84
|
+
|
85
|
+
# Always release the connection after processing is done. Otherwise thread may hang
|
86
|
+
# blocking the reload and further processing
|
87
|
+
# @see https://github.com/rails/rails/issues/44183
|
88
|
+
ActiveRecord::Base.connection_pool.release_connection
|
89
|
+
end
|
80
90
|
end
|
81
91
|
|
82
92
|
initializer 'karafka.require_karafka_boot_file' do |app|
|
data/lib/karafka/version.rb
CHANGED
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.
|
4
|
+
version: 2.0.2
|
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-08-
|
37
|
+
date: 2022-08-07 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: karafka-core
|
@@ -152,7 +152,6 @@ files:
|
|
152
152
|
- bin/scenario
|
153
153
|
- bin/stress_many
|
154
154
|
- bin/stress_one
|
155
|
-
- bin/wait_for_kafka
|
156
155
|
- certs/karafka-pro.pem
|
157
156
|
- certs/mensfeld.pem
|
158
157
|
- config/errors.yml
|
@@ -166,6 +165,7 @@ files:
|
|
166
165
|
- lib/karafka/active_job/job_extensions.rb
|
167
166
|
- lib/karafka/active_job/job_options_contract.rb
|
168
167
|
- lib/karafka/active_job/routing/extensions.rb
|
168
|
+
- lib/karafka/admin.rb
|
169
169
|
- lib/karafka/app.rb
|
170
170
|
- lib/karafka/base_consumer.rb
|
171
171
|
- lib/karafka/cli.rb
|
@@ -287,9 +287,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
287
287
|
version: 2.7.0
|
288
288
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
|
-
- - "
|
290
|
+
- - ">="
|
291
291
|
- !ruby/object:Gem::Version
|
292
|
-
version:
|
292
|
+
version: '0'
|
293
293
|
requirements: []
|
294
294
|
rubygems_version: 3.3.7
|
295
295
|
signing_key:
|
metadata.gz.sig
CHANGED
Binary file
|
data/bin/wait_for_kafka
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# This script allows us to wait for Kafka docker to fully be ready
|
4
|
-
# We consider it fully ready when all our topics that need to be created are created as expected
|
5
|
-
|
6
|
-
KAFKA_NAME='karafka_20_kafka'
|
7
|
-
ZOOKEEPER='zookeeper:2181'
|
8
|
-
LIST_CMD="kafka-topics.sh --list --zookeeper $ZOOKEEPER"
|
9
|
-
|
10
|
-
# Take the number of topics that we need to create prior to running anything
|
11
|
-
TOPICS_COUNT=`cat docker-compose.yml | grep -E -i 'integrations_|benchmarks_' | wc -l`
|
12
|
-
|
13
|
-
# And wait until all of them are created
|
14
|
-
until (((`docker exec $KAFKA_NAME $LIST_CMD | wc -l`) >= $TOPICS_COUNT));
|
15
|
-
do
|
16
|
-
echo "Waiting for Kafka to create all the needed topics..."
|
17
|
-
sleep 1
|
18
|
-
done
|
19
|
-
|
20
|
-
echo "All the needed topics created."
|