karafka 2.0.38 → 2.0.40
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 +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +34 -0
- data/Gemfile.lock +4 -4
- data/bin/integrations +1 -1
- data/config/locales/errors.yml +0 -7
- data/config/locales/pro_errors.yml +18 -0
- data/lib/karafka/base_consumer.rb +35 -55
- data/lib/karafka/connection/listener.rb +15 -10
- data/lib/karafka/errors.rb +0 -3
- data/lib/karafka/instrumentation/logger_listener.rb +44 -3
- data/lib/karafka/instrumentation/notifications.rb +4 -0
- data/lib/karafka/messages/builders/batch_metadata.rb +6 -5
- data/lib/karafka/messages/builders/messages.rb +3 -1
- data/lib/karafka/messages/messages.rb +5 -0
- data/lib/karafka/pro/active_job/consumer.rb +10 -1
- data/lib/karafka/pro/processing/coordinator.rb +13 -4
- 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_applier.rb +100 -0
- data/lib/karafka/pro/processing/jobs_builder.rb +7 -3
- data/lib/karafka/pro/processing/scheduler.rb +24 -7
- 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 +62 -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/{dlq_lrj_vp.rb → aj/lrj_mom.rb} +14 -13
- data/lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb +77 -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/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 +74 -0
- data/lib/karafka/pro/processing/strategies/{mom.rb → dlq/ftr_lrj_vp.rb} +16 -19
- data/lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb +73 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb +39 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj.rb +63 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb +66 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb +38 -0
- data/lib/karafka/pro/processing/strategies/dlq/mom.rb +67 -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 +85 -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/{vp.rb → lrj/ftr_vp.rb} +15 -13
- data/lib/karafka/pro/processing/strategies/lrj/mom.rb +78 -0
- data/lib/karafka/pro/processing/strategies/{aj_lrj_mom.rb → lrj/vp.rb} +13 -12
- 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/vp/default.rb +53 -0
- data/lib/karafka/pro/processing/{strategies/lrj_vp.rb → strategies.rb} +1 -13
- data/lib/karafka/pro/processing/strategy_selector.rb +44 -18
- data/lib/karafka/pro/{processing/strategies/aj_mom.rb → routing/features/delaying/config.rb} +7 -13
- 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/contract.rb +1 -1
- 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/processing/coordinator.rb +60 -30
- data/lib/karafka/processing/coordinators_buffer.rb +5 -1
- data/lib/karafka/processing/executor.rb +37 -21
- data/lib/karafka/processing/executors_buffer.rb +10 -26
- data/lib/karafka/processing/jobs/consume.rb +2 -4
- data/lib/karafka/processing/jobs/idle.rb +24 -0
- data/lib/karafka/processing/jobs_builder.rb +2 -3
- data/lib/karafka/processing/result.rb +5 -0
- data/lib/karafka/processing/strategies/aj_dlq_mom.rb +1 -1
- data/lib/karafka/processing/strategies/base.rb +5 -0
- data/lib/karafka/processing/strategies/default.rb +50 -0
- data/lib/karafka/processing/strategies/dlq.rb +13 -4
- data/lib/karafka/processing/strategies/dlq_mom.rb +8 -3
- data/lib/karafka/processing/strategy_selector.rb +27 -10
- data/lib/karafka/version.rb +1 -1
- data/renovate.json +6 -0
- data.tar.gz.sig +0 -0
- metadata +66 -22
- metadata.gz.sig +0 -0
- data/lib/karafka/pro/processing/strategies/aj_dlq_lrj_mom.rb +0 -42
- data/lib/karafka/pro/processing/strategies/aj_dlq_lrj_mom_vp.rb +0 -70
- data/lib/karafka/pro/processing/strategies/aj_dlq_mom.rb +0 -62
- data/lib/karafka/pro/processing/strategies/aj_dlq_mom_vp.rb +0 -68
- data/lib/karafka/pro/processing/strategies/aj_lrj_mom_vp.rb +0 -75
- data/lib/karafka/pro/processing/strategies/aj_mom_vp.rb +0 -62
- data/lib/karafka/pro/processing/strategies/dlq.rb +0 -120
- data/lib/karafka/pro/processing/strategies/dlq_lrj.rb +0 -65
- data/lib/karafka/pro/processing/strategies/dlq_lrj_mom.rb +0 -62
- data/lib/karafka/pro/processing/strategies/dlq_mom.rb +0 -62
- data/lib/karafka/pro/processing/strategies/dlq_vp.rb +0 -37
- data/lib/karafka/pro/processing/strategies/lrj.rb +0 -83
- data/lib/karafka/pro/processing/strategies/lrj_mom.rb +0 -73
@@ -0,0 +1,62 @@
|
|
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
|
+
# DLQ enabled
|
21
|
+
# Long-Running Job enabled
|
22
|
+
# Manual offset management enabled
|
23
|
+
#
|
24
|
+
# This case is a bit of special. Please see the `AjDlqMom` for explanation on how the
|
25
|
+
# offset management works in this case.
|
26
|
+
module DlqLrjMom
|
27
|
+
include Strategies::Aj::DlqLrjMomVp
|
28
|
+
|
29
|
+
# Features for this strategy
|
30
|
+
FEATURES = %i[
|
31
|
+
active_job
|
32
|
+
dead_letter_queue
|
33
|
+
long_running_job
|
34
|
+
manual_offset_management
|
35
|
+
].freeze
|
36
|
+
|
37
|
+
# We cannot use a VP version of this, because non-VP can early stop on shutdown
|
38
|
+
def handle_after_consume
|
39
|
+
coordinator.on_finished do
|
40
|
+
if coordinator.success?
|
41
|
+
coordinator.pause_tracker.reset
|
42
|
+
|
43
|
+
seek(coordinator.seek_offset) unless revoked?
|
44
|
+
|
45
|
+
resume
|
46
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
47
|
+
retry_after_pause
|
48
|
+
else
|
49
|
+
coordinator.pause_tracker.reset
|
50
|
+
skippable_message, = find_skippable_message
|
51
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
52
|
+
mark_as_consumed(skippable_message)
|
53
|
+
pause(coordinator.seek_offset, nil, false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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
|
+
# DLQ enabled
|
21
|
+
# Long-Running Job enabled
|
22
|
+
# Manual offset management enabled
|
23
|
+
# Virtual Partitions enabled
|
24
|
+
#
|
25
|
+
# This case is a bit of special. Please see the `Aj::DlqMom` for explanation on how the
|
26
|
+
# offset management works in this case.
|
27
|
+
module DlqLrjMomVp
|
28
|
+
include Strategies::Aj::DlqMomVp
|
29
|
+
include Strategies::Aj::LrjMom
|
30
|
+
|
31
|
+
# Features for this strategy
|
32
|
+
FEATURES = %i[
|
33
|
+
active_job
|
34
|
+
dead_letter_queue
|
35
|
+
long_running_job
|
36
|
+
manual_offset_management
|
37
|
+
virtual_partitions
|
38
|
+
].freeze
|
39
|
+
|
40
|
+
# This strategy assumes we do not early break on shutdown as it has VP
|
41
|
+
def handle_after_consume
|
42
|
+
coordinator.on_finished do |last_group_message|
|
43
|
+
if coordinator.success?
|
44
|
+
coordinator.pause_tracker.reset
|
45
|
+
|
46
|
+
# Since we have VP here we do not commit intermediate offsets and need to commit
|
47
|
+
# them here. We do commit in collapsed mode but this is generalized.
|
48
|
+
mark_as_consumed(last_group_message) unless revoked?
|
49
|
+
seek(coordinator.seek_offset) unless revoked?
|
50
|
+
|
51
|
+
resume
|
52
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
53
|
+
retry_after_pause
|
54
|
+
else
|
55
|
+
coordinator.pause_tracker.reset
|
56
|
+
skippable_message, = find_skippable_message
|
57
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
58
|
+
mark_as_consumed(skippable_message)
|
59
|
+
pause(coordinator.seek_offset, nil, false)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
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
|
+
# DLQ enabled
|
21
|
+
# Manual offset management enabled
|
22
|
+
#
|
23
|
+
# AJ has manual offset management on by default and the offset management is delegated to
|
24
|
+
# the AJ consumer. This means, we cannot mark as consumed always. We can only mark as
|
25
|
+
# consumed when we skip given job upon errors. In all the other scenarios marking as
|
26
|
+
# consumed needs to happen in the AJ consumer on a per job basis.
|
27
|
+
module DlqMom
|
28
|
+
include Strategies::Dlq::Mom
|
29
|
+
|
30
|
+
# Features for this strategy
|
31
|
+
FEATURES = %i[
|
32
|
+
active_job
|
33
|
+
dead_letter_queue
|
34
|
+
manual_offset_management
|
35
|
+
].freeze
|
36
|
+
|
37
|
+
# How should we post-finalize consumption.
|
38
|
+
def handle_after_consume
|
39
|
+
coordinator.on_finished do
|
40
|
+
return if revoked?
|
41
|
+
|
42
|
+
if coordinator.success?
|
43
|
+
# Do NOT commit offsets, they are comitted after each job in the AJ consumer.
|
44
|
+
coordinator.pause_tracker.reset
|
45
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
46
|
+
retry_after_pause
|
47
|
+
else
|
48
|
+
coordinator.pause_tracker.reset
|
49
|
+
skippable_message, = find_skippable_message
|
50
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
51
|
+
# We can commit the offset here because we know that we skip it "forever" and
|
52
|
+
# since AJ consumer commits the offset after each job, we also know that the
|
53
|
+
# previous job was successful
|
54
|
+
mark_as_consumed(skippable_message)
|
55
|
+
pause(coordinator.seek_offset, nil, false)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -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::Dlq::Default
|
24
|
+
include Strategies::Vp::Default
|
25
|
+
include Strategies::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
|
@@ -15,20 +15,21 @@ module Karafka
|
|
15
15
|
module Pro
|
16
16
|
module Processing
|
17
17
|
module Strategies
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
# Features for this strategy
|
27
|
+
FEATURES = %i[
|
28
|
+
active_job
|
29
|
+
long_running_job
|
30
|
+
manual_offset_management
|
31
|
+
].freeze
|
32
|
+
end
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -0,0 +1,77 @@
|
|
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
|
+
coordinator.on_enqueued do
|
38
|
+
pause(coordinator.seek_offset, Strategies::Lrj::Default::MAX_PAUSE_TIME, false)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Standard flow without any features
|
43
|
+
def handle_after_consume
|
44
|
+
coordinator.on_finished do |last_group_message|
|
45
|
+
if coordinator.success?
|
46
|
+
coordinator.pause_tracker.reset
|
47
|
+
|
48
|
+
mark_as_consumed(last_group_message) unless revoked?
|
49
|
+
seek(coordinator.seek_offset) unless revoked?
|
50
|
+
|
51
|
+
resume
|
52
|
+
else
|
53
|
+
# If processing failed, we need to pause
|
54
|
+
# For long running job this will overwrite the default never-ending pause and
|
55
|
+
# will cause the processing to keep going after the error backoff
|
56
|
+
retry_after_pause
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# LRJ cannot resume here. Only in handling the after consumption
|
62
|
+
def handle_revoked
|
63
|
+
coordinator.on_revoked do
|
64
|
+
coordinator.revoke
|
65
|
+
end
|
66
|
+
|
67
|
+
Karafka.monitor.instrument('consumer.revoke', caller: self)
|
68
|
+
Karafka.monitor.instrument('consumer.revoked', caller: self) do
|
69
|
+
revoked
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
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::Vp::Default
|
24
|
+
include Strategies::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
|