karafka 2.0.0 → 2.1.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/ci.yml +40 -16
- data/.rspec +4 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +459 -796
- data/Gemfile +3 -2
- data/Gemfile.lock +44 -32
- data/LICENSE +1 -1
- data/README.md +22 -17
- data/bin/integrations +86 -26
- data/bin/karafka +1 -13
- data/bin/rspecs +6 -0
- data/bin/verify_license_integrity +37 -0
- data/certs/cert_chain.pem +26 -0
- data/config/{errors.yml → locales/errors.yml} +34 -6
- data/config/locales/pro_errors.yml +34 -0
- data/docker-compose.yml +4 -30
- data/karafka.gemspec +17 -10
- data/lib/active_job/karafka.rb +3 -7
- data/lib/active_job/queue_adapters/karafka_adapter.rb +7 -1
- data/lib/karafka/active_job/consumer.rb +29 -6
- data/lib/karafka/active_job/current_attributes/loading.rb +36 -0
- data/lib/karafka/active_job/current_attributes/persistence.rb +28 -0
- data/lib/karafka/active_job/current_attributes.rb +42 -0
- data/lib/karafka/active_job/dispatcher.rb +34 -3
- data/lib/karafka/active_job/job_options_contract.rb +13 -2
- data/lib/karafka/admin.rb +246 -0
- data/lib/karafka/app.rb +30 -7
- data/lib/karafka/base_consumer.rb +124 -82
- data/lib/karafka/cli/base.rb +20 -0
- data/lib/karafka/cli/console.rb +13 -8
- data/lib/karafka/cli/info.rb +3 -2
- data/lib/karafka/cli/server.rb +55 -8
- data/lib/karafka/cli/topics.rb +146 -0
- data/lib/karafka/connection/client.rb +118 -61
- data/lib/karafka/connection/consumer_group_coordinator.rb +48 -0
- data/lib/karafka/connection/listener.rb +78 -30
- data/lib/karafka/connection/listeners_batch.rb +18 -2
- data/lib/karafka/connection/rebalance_manager.rb +3 -0
- data/lib/karafka/contracts/config.rb +1 -1
- data/lib/karafka/contracts/consumer_group.rb +22 -9
- data/lib/karafka/contracts/server_cli_options.rb +71 -11
- data/lib/karafka/contracts/topic.rb +65 -0
- data/lib/karafka/contracts.rb +1 -1
- data/lib/karafka/embedded.rb +36 -0
- data/lib/karafka/errors.rb +6 -4
- data/lib/karafka/helpers/colorize.rb +6 -0
- data/lib/karafka/instrumentation/callbacks/error.rb +3 -4
- data/lib/karafka/instrumentation/callbacks/statistics.rb +14 -4
- data/lib/karafka/instrumentation/logger_listener.rb +151 -22
- data/lib/karafka/instrumentation/notifications.rb +26 -7
- data/lib/karafka/instrumentation/proctitle_listener.rb +7 -16
- data/lib/karafka/instrumentation/vendors/datadog/dashboard.json +1 -1
- data/lib/karafka/instrumentation/vendors/datadog/logger_listener.rb +153 -0
- data/lib/karafka/instrumentation/vendors/datadog/{listener.rb → metrics_listener.rb} +62 -35
- data/lib/karafka/instrumentation/vendors/kubernetes/liveness_listener.rb +166 -0
- data/lib/karafka/licenser.rb +53 -50
- data/lib/karafka/messages/builders/batch_metadata.rb +8 -8
- data/lib/karafka/messages/builders/messages.rb +6 -2
- data/lib/karafka/messages/message.rb +14 -2
- data/lib/karafka/messages/messages.rb +5 -0
- data/lib/karafka/messages/parser.rb +14 -0
- data/lib/karafka/patches/rdkafka/bindings.rb +132 -0
- data/lib/karafka/pro/active_job/consumer.rb +10 -9
- data/lib/karafka/pro/active_job/dispatcher.rb +28 -3
- data/lib/karafka/pro/active_job/job_options_contract.rb +16 -3
- data/lib/karafka/pro/encryption/cipher.rb +58 -0
- data/lib/karafka/pro/encryption/contracts/config.rb +79 -0
- data/lib/karafka/pro/encryption/errors.rb +24 -0
- data/lib/karafka/pro/encryption/messages/middleware.rb +46 -0
- data/lib/karafka/pro/encryption/messages/parser.rb +56 -0
- data/lib/karafka/pro/encryption/setup/config.rb +48 -0
- data/lib/karafka/pro/encryption.rb +47 -0
- data/lib/karafka/pro/iterator.rb +253 -0
- data/lib/karafka/pro/loader.rb +52 -26
- data/lib/karafka/pro/performance_tracker.rb +10 -6
- data/lib/karafka/pro/processing/collapser.rb +62 -0
- data/lib/karafka/pro/processing/coordinator.rb +92 -16
- data/lib/karafka/pro/processing/filters/base.rb +61 -0
- data/lib/karafka/pro/processing/filters/delayer.rb +70 -0
- data/lib/karafka/pro/processing/filters/expirer.rb +51 -0
- data/lib/karafka/pro/processing/filters/throttler.rb +84 -0
- data/lib/karafka/pro/processing/filters/virtual_limiter.rb +52 -0
- data/lib/karafka/pro/processing/filters_applier.rb +104 -0
- data/lib/karafka/pro/processing/jobs/consume_non_blocking.rb +7 -5
- data/lib/karafka/pro/processing/jobs/revoked_non_blocking.rb +37 -0
- data/lib/karafka/pro/processing/jobs_builder.rb +22 -4
- data/lib/karafka/pro/processing/partitioner.rb +33 -24
- data/lib/karafka/pro/processing/scheduler.rb +27 -8
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom.rb +68 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom_vp.rb +74 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom.rb +72 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom_vp.rb +76 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom.rb +64 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom_vp.rb +68 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_mom.rb +64 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_mom_vp.rb +69 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom.rb +38 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom_vp.rb +64 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_mom.rb +38 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_mom_vp.rb +58 -0
- data/lib/karafka/pro/processing/strategies/aj/lrj_mom.rb +37 -0
- data/lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb +79 -0
- data/lib/karafka/pro/processing/strategies/aj/mom.rb +36 -0
- data/lib/karafka/pro/processing/strategies/aj/mom_vp.rb +52 -0
- data/lib/karafka/pro/processing/strategies/base.rb +26 -0
- data/lib/karafka/pro/processing/strategies/default.rb +105 -0
- data/lib/karafka/pro/processing/strategies/dlq/default.rb +131 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr.rb +61 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj.rb +75 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom.rb +71 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom_vp.rb +43 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_vp.rb +41 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb +69 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_mom_vp.rb +41 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj.rb +63 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb +63 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_mom_vp.rb +36 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb +39 -0
- data/lib/karafka/pro/processing/strategies/dlq/mom.rb +68 -0
- data/lib/karafka/pro/processing/strategies/dlq/mom_vp.rb +37 -0
- data/lib/karafka/pro/processing/strategies/dlq/vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/ftr/default.rb +104 -0
- data/lib/karafka/pro/processing/strategies/ftr/vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/lrj/default.rb +87 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr.rb +69 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr_mom.rb +67 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr_mom_vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr_vp.rb +39 -0
- data/lib/karafka/pro/processing/strategies/lrj/mom.rb +80 -0
- data/lib/karafka/pro/processing/strategies/lrj/mom_vp.rb +38 -0
- data/lib/karafka/pro/processing/strategies/lrj/vp.rb +36 -0
- data/lib/karafka/pro/processing/strategies/mom/default.rb +46 -0
- data/lib/karafka/pro/processing/strategies/mom/ftr.rb +53 -0
- data/lib/karafka/pro/processing/strategies/mom/ftr_vp.rb +37 -0
- data/lib/karafka/pro/processing/strategies/mom/vp.rb +35 -0
- data/lib/karafka/pro/processing/strategies/vp/default.rb +104 -0
- data/lib/karafka/pro/{contracts/base.rb → processing/strategies.rb} +6 -5
- data/lib/karafka/pro/processing/strategy_selector.rb +84 -0
- data/lib/karafka/pro/processing/virtual_offset_manager.rb +147 -0
- data/lib/karafka/pro/routing/features/base.rb +24 -0
- data/lib/karafka/pro/routing/features/dead_letter_queue/contract.rb +50 -0
- data/lib/karafka/pro/routing/features/dead_letter_queue.rb +27 -0
- data/lib/karafka/pro/routing/{builder_extensions.rb → features/delaying/config.rb} +8 -11
- data/lib/karafka/pro/routing/features/delaying/contract.rb +38 -0
- data/lib/karafka/pro/routing/features/delaying/topic.rb +59 -0
- data/lib/karafka/pro/routing/features/delaying.rb +29 -0
- data/lib/karafka/pro/routing/features/expiring/config.rb +27 -0
- data/lib/karafka/pro/routing/features/expiring/contract.rb +38 -0
- data/lib/karafka/pro/routing/features/expiring/topic.rb +59 -0
- data/lib/karafka/pro/routing/features/expiring.rb +27 -0
- data/lib/karafka/pro/routing/features/filtering/config.rb +40 -0
- data/lib/karafka/pro/routing/features/filtering/contract.rb +41 -0
- data/lib/karafka/pro/routing/features/filtering/topic.rb +51 -0
- data/lib/karafka/pro/routing/features/filtering.rb +27 -0
- data/lib/karafka/pro/routing/features/long_running_job/config.rb +28 -0
- data/lib/karafka/pro/routing/features/long_running_job/contract.rb +37 -0
- data/lib/karafka/pro/routing/features/long_running_job/topic.rb +42 -0
- data/lib/karafka/pro/routing/features/long_running_job.rb +28 -0
- data/lib/karafka/pro/routing/features/throttling/config.rb +32 -0
- data/lib/karafka/pro/routing/features/throttling/contract.rb +41 -0
- data/lib/karafka/pro/routing/features/throttling/topic.rb +69 -0
- data/lib/karafka/pro/routing/features/throttling.rb +30 -0
- data/lib/karafka/pro/routing/features/virtual_partitions/config.rb +30 -0
- data/lib/karafka/pro/routing/features/virtual_partitions/contract.rb +52 -0
- data/lib/karafka/pro/routing/features/virtual_partitions/topic.rb +56 -0
- data/lib/karafka/pro/routing/features/virtual_partitions.rb +27 -0
- data/lib/karafka/process.rb +23 -8
- data/lib/karafka/processing/coordinator.rb +102 -23
- data/lib/karafka/processing/coordinators_buffer.rb +5 -1
- data/lib/karafka/processing/executor.rb +51 -21
- data/lib/karafka/processing/executors_buffer.rb +10 -26
- data/lib/karafka/processing/jobs/base.rb +6 -2
- data/lib/karafka/processing/jobs/consume.rb +8 -5
- data/lib/karafka/processing/jobs/idle.rb +24 -0
- data/lib/karafka/processing/jobs_builder.rb +2 -3
- data/lib/karafka/processing/jobs_queue.rb +14 -8
- data/lib/karafka/processing/partitioner.rb +3 -1
- data/lib/karafka/processing/result.rb +14 -1
- data/lib/karafka/processing/strategies/aj_dlq_mom.rb +44 -0
- data/lib/karafka/processing/strategies/aj_mom.rb +21 -0
- data/lib/karafka/processing/strategies/base.rb +52 -0
- data/lib/karafka/processing/strategies/default.rb +142 -0
- data/lib/karafka/processing/strategies/dlq.rb +88 -0
- data/lib/karafka/processing/strategies/dlq_mom.rb +49 -0
- data/lib/karafka/processing/strategies/mom.rb +29 -0
- data/lib/karafka/processing/strategy_selector.rb +47 -0
- data/lib/karafka/processing/worker.rb +8 -3
- data/lib/karafka/railtie.rb +24 -12
- data/lib/karafka/routing/activity_manager.rb +84 -0
- data/lib/karafka/routing/builder.rb +20 -0
- data/lib/karafka/routing/consumer_group.rb +38 -4
- data/lib/karafka/routing/consumer_mapper.rb +0 -10
- data/lib/karafka/routing/features/active_job/builder.rb +33 -0
- data/lib/karafka/routing/features/active_job/config.rb +15 -0
- data/lib/karafka/routing/features/active_job/contract.rb +41 -0
- data/lib/karafka/routing/features/active_job/topic.rb +33 -0
- data/lib/karafka/routing/features/active_job.rb +13 -0
- data/lib/karafka/routing/features/base/expander.rb +53 -0
- data/lib/karafka/routing/features/base.rb +34 -0
- data/lib/karafka/routing/features/dead_letter_queue/config.rb +19 -0
- data/lib/karafka/routing/features/dead_letter_queue/contract.rb +42 -0
- data/lib/karafka/routing/features/dead_letter_queue/topic.rb +41 -0
- data/lib/karafka/routing/features/dead_letter_queue.rb +16 -0
- data/lib/karafka/routing/features/declaratives/config.rb +18 -0
- data/lib/karafka/routing/features/declaratives/contract.rb +30 -0
- data/lib/karafka/routing/features/declaratives/topic.rb +44 -0
- data/lib/karafka/routing/features/declaratives.rb +14 -0
- data/lib/karafka/routing/features/manual_offset_management/config.rb +15 -0
- data/lib/karafka/routing/features/manual_offset_management/contract.rb +24 -0
- data/lib/karafka/routing/features/manual_offset_management/topic.rb +35 -0
- data/lib/karafka/routing/features/manual_offset_management.rb +18 -0
- data/lib/karafka/routing/proxy.rb +18 -20
- data/lib/karafka/routing/router.rb +27 -2
- data/lib/karafka/routing/subscription_group.rb +43 -5
- data/lib/karafka/routing/subscription_groups_builder.rb +6 -1
- data/lib/karafka/routing/topic.rb +17 -5
- data/lib/karafka/routing/topics.rb +8 -0
- data/lib/karafka/runner.rb +1 -0
- data/lib/karafka/serialization/json/deserializer.rb +1 -0
- data/lib/karafka/server.rb +58 -28
- data/lib/karafka/setup/attributes_map.rb +344 -0
- data/lib/karafka/setup/config.rb +48 -19
- data/lib/karafka/status.rb +35 -7
- data/lib/karafka/templates/karafka.rb.erb +14 -6
- data/lib/karafka/time_trackers/base.rb +1 -6
- data/lib/karafka/time_trackers/pause.rb +49 -19
- data/lib/karafka/time_trackers/poll.rb +7 -3
- data/lib/karafka/version.rb +1 -1
- data/lib/karafka.rb +56 -3
- data/renovate.json +6 -0
- data.tar.gz.sig +0 -0
- metadata +189 -61
- metadata.gz.sig +0 -0
- data/bin/wait_for_kafka +0 -20
- data/certs/mensfeld.pem +0 -25
- data/lib/karafka/active_job/routing/extensions.rb +0 -31
- data/lib/karafka/contracts/consumer_group_topic.rb +0 -42
- data/lib/karafka/instrumentation.rb +0 -21
- data/lib/karafka/pro/base_consumer.rb +0 -82
- data/lib/karafka/pro/contracts/consumer_group.rb +0 -34
- data/lib/karafka/pro/contracts/consumer_group_topic.rb +0 -33
- data/lib/karafka/pro/routing/topic_extensions.rb +0 -38
|
@@ -0,0 +1,69 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
module Aj
|
|
19
|
+
# ActiveJob enabled
|
|
20
|
+
# Manual offset management enabled
|
|
21
|
+
# Virtual Partitions enabled
|
|
22
|
+
module DlqMomVp
|
|
23
|
+
include Strategies::Default
|
|
24
|
+
include Strategies::Dlq::Vp
|
|
25
|
+
include Strategies::Vp::Default
|
|
26
|
+
|
|
27
|
+
# Features for this strategy
|
|
28
|
+
FEATURES = %i[
|
|
29
|
+
active_job
|
|
30
|
+
dead_letter_queue
|
|
31
|
+
manual_offset_management
|
|
32
|
+
virtual_partitions
|
|
33
|
+
].freeze
|
|
34
|
+
|
|
35
|
+
# Flow including moving to DLQ in the collapsed mode
|
|
36
|
+
def handle_after_consume
|
|
37
|
+
coordinator.on_finished do |last_group_message|
|
|
38
|
+
if coordinator.success?
|
|
39
|
+
coordinator.pause_tracker.reset
|
|
40
|
+
|
|
41
|
+
# When this is an ActiveJob running via Pro with virtual partitions, we cannot
|
|
42
|
+
# mark intermediate jobs as processed not to mess up with the ordering.
|
|
43
|
+
# Only when all the jobs are processed and we did not loose the partition
|
|
44
|
+
# assignment and we are not stopping (Pro ActiveJob has an early break) we can
|
|
45
|
+
# commit offsets .
|
|
46
|
+
# For a non virtual partitions case, the flow is regular and state is marked
|
|
47
|
+
# after each successfully processed job
|
|
48
|
+
return if revoked?
|
|
49
|
+
|
|
50
|
+
mark_as_consumed(last_group_message)
|
|
51
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
|
52
|
+
retry_after_pause
|
|
53
|
+
else
|
|
54
|
+
# Here we are in a collapsed state, hence we can apply the same logic as
|
|
55
|
+
# Aj::DlqMom
|
|
56
|
+
coordinator.pause_tracker.reset
|
|
57
|
+
skippable_message, = find_skippable_message
|
|
58
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
|
59
|
+
mark_as_consumed(skippable_message)
|
|
60
|
+
pause(coordinator.seek_offset, nil, false)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
module Aj
|
|
19
|
+
# ActiveJob enabled
|
|
20
|
+
# Filtering enabled
|
|
21
|
+
# Long-Running Job enabled
|
|
22
|
+
# Manual offset management enabled
|
|
23
|
+
module FtrLrjMom
|
|
24
|
+
include Strategies::Lrj::FtrMom
|
|
25
|
+
|
|
26
|
+
# Features for this strategy
|
|
27
|
+
FEATURES = %i[
|
|
28
|
+
active_job
|
|
29
|
+
filtering
|
|
30
|
+
long_running_job
|
|
31
|
+
manual_offset_management
|
|
32
|
+
].freeze
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
module Aj
|
|
19
|
+
# ActiveJob enabled
|
|
20
|
+
# Filtering enabled
|
|
21
|
+
# Long-Running Job enabled
|
|
22
|
+
# Manual offset management enabled
|
|
23
|
+
# Virtual Partitions enabled
|
|
24
|
+
module FtrLrjMomVp
|
|
25
|
+
include Strategies::Vp::Default
|
|
26
|
+
include Strategies::Lrj::FtrMom
|
|
27
|
+
|
|
28
|
+
# Features for this strategy
|
|
29
|
+
FEATURES = %i[
|
|
30
|
+
active_job
|
|
31
|
+
filtering
|
|
32
|
+
long_running_job
|
|
33
|
+
manual_offset_management
|
|
34
|
+
virtual_partitions
|
|
35
|
+
].freeze
|
|
36
|
+
|
|
37
|
+
# AJ MOM VP does not do intermediate marking, hence we need to make sure we mark as
|
|
38
|
+
# consumed here.
|
|
39
|
+
def handle_after_consume
|
|
40
|
+
coordinator.on_finished do |last_group_message|
|
|
41
|
+
if coordinator.success?
|
|
42
|
+
coordinator.pause_tracker.reset
|
|
43
|
+
|
|
44
|
+
mark_as_consumed(last_group_message) unless revoked?
|
|
45
|
+
|
|
46
|
+
if coordinator.filtered? && !revoked?
|
|
47
|
+
handle_post_filtering
|
|
48
|
+
elsif !revoked?
|
|
49
|
+
seek(coordinator.seek_offset)
|
|
50
|
+
resume
|
|
51
|
+
else
|
|
52
|
+
resume
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
retry_after_pause
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
# Namespace for ActiveJob related strategies
|
|
19
|
+
module Aj
|
|
20
|
+
# ActiveJob enabled
|
|
21
|
+
# Filtering enabled
|
|
22
|
+
# Manual Offset management enabled
|
|
23
|
+
module FtrMom
|
|
24
|
+
# Same as standard Mom::Ftr
|
|
25
|
+
include Strategies::Mom::Ftr
|
|
26
|
+
|
|
27
|
+
# Features for this strategy
|
|
28
|
+
FEATURES = %i[
|
|
29
|
+
active_job
|
|
30
|
+
filtering
|
|
31
|
+
manual_offset_management
|
|
32
|
+
].freeze
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
# Namespace for ActiveJob related strategies
|
|
19
|
+
module Aj
|
|
20
|
+
# ActiveJob enabled
|
|
21
|
+
# Filtering enabled
|
|
22
|
+
# Manual Offset management enabled
|
|
23
|
+
# Virtual partitions enabled
|
|
24
|
+
module FtrMomVp
|
|
25
|
+
include Strategies::Aj::FtrMom
|
|
26
|
+
include Strategies::Aj::MomVp
|
|
27
|
+
|
|
28
|
+
# Features for this strategy
|
|
29
|
+
FEATURES = %i[
|
|
30
|
+
active_job
|
|
31
|
+
filtering
|
|
32
|
+
manual_offset_management
|
|
33
|
+
virtual_partitions
|
|
34
|
+
].freeze
|
|
35
|
+
|
|
36
|
+
# AJ with VPs always has intermediate marking disabled, hence we need to do it post
|
|
37
|
+
# execution always.
|
|
38
|
+
def handle_after_consume
|
|
39
|
+
coordinator.on_finished do |last_group_message|
|
|
40
|
+
if coordinator.success?
|
|
41
|
+
coordinator.pause_tracker.reset
|
|
42
|
+
|
|
43
|
+
return if revoked?
|
|
44
|
+
|
|
45
|
+
mark_as_consumed(last_group_message)
|
|
46
|
+
|
|
47
|
+
handle_post_filtering
|
|
48
|
+
else
|
|
49
|
+
retry_after_pause
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
module Aj
|
|
19
|
+
# ActiveJob enabled
|
|
20
|
+
# Long-Running Job enabled
|
|
21
|
+
# Manual offset management enabled
|
|
22
|
+
module LrjMom
|
|
23
|
+
# Same behaviour as Lrj::Mom
|
|
24
|
+
include Strategies::Lrj::Mom
|
|
25
|
+
|
|
26
|
+
# Features for this strategy
|
|
27
|
+
FEATURES = %i[
|
|
28
|
+
active_job
|
|
29
|
+
long_running_job
|
|
30
|
+
manual_offset_management
|
|
31
|
+
].freeze
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
module Aj
|
|
19
|
+
# ActiveJob enabled
|
|
20
|
+
# Long-Running Job enabled
|
|
21
|
+
# Manual offset management enabled
|
|
22
|
+
# Virtual Partitions enabled
|
|
23
|
+
module LrjMomVp
|
|
24
|
+
include Strategies::Default
|
|
25
|
+
include Strategies::Vp::Default
|
|
26
|
+
|
|
27
|
+
# Features for this strategy
|
|
28
|
+
FEATURES = %i[
|
|
29
|
+
active_job
|
|
30
|
+
long_running_job
|
|
31
|
+
manual_offset_management
|
|
32
|
+
virtual_partitions
|
|
33
|
+
].freeze
|
|
34
|
+
|
|
35
|
+
# No actions needed for the standard flow here
|
|
36
|
+
def handle_before_enqueue
|
|
37
|
+
super
|
|
38
|
+
|
|
39
|
+
coordinator.on_enqueued do
|
|
40
|
+
pause(coordinator.seek_offset, Strategies::Lrj::Default::MAX_PAUSE_TIME, false)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Standard flow without any features
|
|
45
|
+
def handle_after_consume
|
|
46
|
+
coordinator.on_finished do |last_group_message|
|
|
47
|
+
if coordinator.success?
|
|
48
|
+
coordinator.pause_tracker.reset
|
|
49
|
+
|
|
50
|
+
mark_as_consumed(last_group_message) unless revoked?
|
|
51
|
+
seek(coordinator.seek_offset) unless revoked?
|
|
52
|
+
|
|
53
|
+
resume
|
|
54
|
+
else
|
|
55
|
+
# If processing failed, we need to pause
|
|
56
|
+
# For long running job this will overwrite the default never-ending pause and
|
|
57
|
+
# will cause the processing to keep going after the error backoff
|
|
58
|
+
retry_after_pause
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# LRJ cannot resume here. Only in handling the after consumption
|
|
64
|
+
def handle_revoked
|
|
65
|
+
coordinator.on_revoked do
|
|
66
|
+
coordinator.revoke
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
Karafka.monitor.instrument('consumer.revoke', caller: self)
|
|
70
|
+
Karafka.monitor.instrument('consumer.revoked', caller: self) do
|
|
71
|
+
revoked
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
# Namespace for ActiveJob related strategies
|
|
19
|
+
module Aj
|
|
20
|
+
# ActiveJob enabled
|
|
21
|
+
# Manual Offset management enabled
|
|
22
|
+
module Mom
|
|
23
|
+
# Standard ActiveJob strategy is the same one we use for Mom
|
|
24
|
+
include Strategies::Mom::Default
|
|
25
|
+
|
|
26
|
+
# Features for this strategy
|
|
27
|
+
FEATURES = %i[
|
|
28
|
+
active_job
|
|
29
|
+
manual_offset_management
|
|
30
|
+
].freeze
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
module Aj
|
|
19
|
+
# ActiveJob enabled
|
|
20
|
+
# Manual offset management enabled
|
|
21
|
+
# Virtual Partitions enabled
|
|
22
|
+
module MomVp
|
|
23
|
+
include Strategies::Default
|
|
24
|
+
include Strategies::Vp::Default
|
|
25
|
+
|
|
26
|
+
# Features for this strategy
|
|
27
|
+
FEATURES = %i[
|
|
28
|
+
active_job
|
|
29
|
+
manual_offset_management
|
|
30
|
+
virtual_partitions
|
|
31
|
+
].freeze
|
|
32
|
+
|
|
33
|
+
# Standard flow without any features
|
|
34
|
+
def handle_after_consume
|
|
35
|
+
coordinator.on_finished do |last_group_message|
|
|
36
|
+
if coordinator.success?
|
|
37
|
+
coordinator.pause_tracker.reset
|
|
38
|
+
|
|
39
|
+
return if revoked?
|
|
40
|
+
|
|
41
|
+
mark_as_consumed(last_group_message)
|
|
42
|
+
else
|
|
43
|
+
retry_after_pause
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
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 Processing
|
|
17
|
+
# Pro processing strategies namespace
|
|
18
|
+
module Strategies
|
|
19
|
+
# Base strategy for Pro
|
|
20
|
+
module Base
|
|
21
|
+
include ::Karafka::Processing::Strategies::Base
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
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 Processing
|
|
17
|
+
module Strategies
|
|
18
|
+
# No features enabled.
|
|
19
|
+
# No manual offset management
|
|
20
|
+
# No long running jobs
|
|
21
|
+
# No virtual partitions
|
|
22
|
+
# Nothing. Just standard, automatic flow
|
|
23
|
+
module Default
|
|
24
|
+
include Base
|
|
25
|
+
include ::Karafka::Processing::Strategies::Default
|
|
26
|
+
|
|
27
|
+
# Apply strategy for a non-feature based flow
|
|
28
|
+
FEATURES = %i[].freeze
|
|
29
|
+
|
|
30
|
+
# No actions needed for the standard flow here
|
|
31
|
+
def handle_before_enqueue
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Increment number of attempts per one "full" job. For all VP on a single topic partition
|
|
36
|
+
# this also should run once.
|
|
37
|
+
def handle_before_consume
|
|
38
|
+
coordinator.on_started do
|
|
39
|
+
coordinator.pause_tracker.increment
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Run the user consumption code
|
|
44
|
+
def handle_consume
|
|
45
|
+
# We should not run the work at all on a partition that was revoked
|
|
46
|
+
# This can happen primarily when an LRJ job gets to the internal worker queue and
|
|
47
|
+
# this partition is revoked prior processing.
|
|
48
|
+
unless revoked?
|
|
49
|
+
Karafka.monitor.instrument('consumer.consume', caller: self)
|
|
50
|
+
Karafka.monitor.instrument('consumer.consumed', caller: self) do
|
|
51
|
+
consume
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Mark job as successful
|
|
56
|
+
coordinator.success!(self)
|
|
57
|
+
rescue StandardError => e
|
|
58
|
+
# If failed, mark as failed
|
|
59
|
+
coordinator.failure!(self, e)
|
|
60
|
+
|
|
61
|
+
# Re-raise so reported in the consumer
|
|
62
|
+
raise e
|
|
63
|
+
ensure
|
|
64
|
+
# We need to decrease number of jobs that this coordinator coordinates as it has
|
|
65
|
+
# finished
|
|
66
|
+
coordinator.decrement
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Standard flow without any features
|
|
70
|
+
def handle_after_consume
|
|
71
|
+
coordinator.on_finished do |last_group_message|
|
|
72
|
+
return if revoked?
|
|
73
|
+
|
|
74
|
+
if coordinator.success?
|
|
75
|
+
coordinator.pause_tracker.reset
|
|
76
|
+
|
|
77
|
+
# Do not mark last message if pause happened. This prevents a scenario where pause
|
|
78
|
+
# is overridden upon rebalance by marking
|
|
79
|
+
return if coordinator.manual_pause?
|
|
80
|
+
|
|
81
|
+
mark_as_consumed(last_group_message)
|
|
82
|
+
else
|
|
83
|
+
retry_after_pause
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Standard
|
|
89
|
+
def handle_revoked
|
|
90
|
+
coordinator.on_revoked do
|
|
91
|
+
resume
|
|
92
|
+
|
|
93
|
+
coordinator.revoke
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
Karafka.monitor.instrument('consumer.revoke', caller: self)
|
|
97
|
+
Karafka.monitor.instrument('consumer.revoked', caller: self) do
|
|
98
|
+
revoked
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|