karafka 2.0.38 → 2.0.39

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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +1 -1
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +28 -0
  6. data/Gemfile.lock +4 -4
  7. data/bin/integrations +1 -1
  8. data/config/locales/errors.yml +0 -7
  9. data/config/locales/pro_errors.yml +18 -0
  10. data/lib/karafka/base_consumer.rb +35 -55
  11. data/lib/karafka/connection/listener.rb +15 -10
  12. data/lib/karafka/errors.rb +0 -3
  13. data/lib/karafka/instrumentation/logger_listener.rb +44 -3
  14. data/lib/karafka/instrumentation/notifications.rb +4 -0
  15. data/lib/karafka/pro/active_job/consumer.rb +10 -1
  16. data/lib/karafka/pro/processing/coordinator.rb +13 -4
  17. data/lib/karafka/pro/processing/filters/base.rb +61 -0
  18. data/lib/karafka/pro/processing/filters/delayer.rb +70 -0
  19. data/lib/karafka/pro/processing/filters/expirer.rb +51 -0
  20. data/lib/karafka/pro/processing/filters/throttler.rb +84 -0
  21. data/lib/karafka/pro/processing/filters_applier.rb +100 -0
  22. data/lib/karafka/pro/processing/jobs_builder.rb +7 -3
  23. data/lib/karafka/pro/processing/scheduler.rb +24 -7
  24. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom.rb +68 -0
  25. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom_vp.rb +74 -0
  26. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom.rb +72 -0
  27. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom_vp.rb +76 -0
  28. data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom.rb +62 -0
  29. data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom_vp.rb +68 -0
  30. data/lib/karafka/pro/processing/strategies/aj/dlq_mom.rb +64 -0
  31. data/lib/karafka/pro/processing/strategies/aj/dlq_mom_vp.rb +69 -0
  32. data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom.rb +38 -0
  33. data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom_vp.rb +64 -0
  34. data/lib/karafka/pro/processing/strategies/aj/ftr_mom.rb +38 -0
  35. data/lib/karafka/pro/processing/strategies/aj/ftr_mom_vp.rb +58 -0
  36. data/lib/karafka/pro/processing/strategies/{dlq_lrj_vp.rb → aj/lrj_mom.rb} +14 -13
  37. data/lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb +77 -0
  38. data/lib/karafka/pro/processing/strategies/aj/mom.rb +36 -0
  39. data/lib/karafka/pro/processing/strategies/aj/mom_vp.rb +52 -0
  40. data/lib/karafka/pro/processing/strategies/dlq/default.rb +131 -0
  41. data/lib/karafka/pro/processing/strategies/dlq/ftr.rb +61 -0
  42. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj.rb +75 -0
  43. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom.rb +74 -0
  44. data/lib/karafka/pro/processing/strategies/{mom.rb → dlq/ftr_lrj_vp.rb} +16 -19
  45. data/lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb +73 -0
  46. data/lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb +39 -0
  47. data/lib/karafka/pro/processing/strategies/dlq/lrj.rb +63 -0
  48. data/lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb +66 -0
  49. data/lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb +38 -0
  50. data/lib/karafka/pro/processing/strategies/dlq/mom.rb +67 -0
  51. data/lib/karafka/pro/processing/strategies/dlq/vp.rb +39 -0
  52. data/lib/karafka/pro/processing/strategies/ftr/default.rb +104 -0
  53. data/lib/karafka/pro/processing/strategies/ftr/vp.rb +40 -0
  54. data/lib/karafka/pro/processing/strategies/lrj/default.rb +85 -0
  55. data/lib/karafka/pro/processing/strategies/lrj/ftr.rb +69 -0
  56. data/lib/karafka/pro/processing/strategies/lrj/ftr_mom.rb +67 -0
  57. data/lib/karafka/pro/processing/strategies/{vp.rb → lrj/ftr_vp.rb} +15 -13
  58. data/lib/karafka/pro/processing/strategies/lrj/mom.rb +78 -0
  59. data/lib/karafka/pro/processing/strategies/{aj_lrj_mom.rb → lrj/vp.rb} +13 -12
  60. data/lib/karafka/pro/processing/strategies/mom/default.rb +46 -0
  61. data/lib/karafka/pro/processing/strategies/mom/ftr.rb +53 -0
  62. data/lib/karafka/pro/processing/strategies/vp/default.rb +53 -0
  63. data/lib/karafka/pro/processing/{strategies/lrj_vp.rb → strategies.rb} +1 -13
  64. data/lib/karafka/pro/processing/strategy_selector.rb +44 -18
  65. data/lib/karafka/pro/{processing/strategies/aj_mom.rb → routing/features/delaying/config.rb} +7 -13
  66. data/lib/karafka/pro/routing/features/delaying/contract.rb +38 -0
  67. data/lib/karafka/pro/routing/features/delaying/topic.rb +59 -0
  68. data/lib/karafka/pro/routing/features/delaying.rb +29 -0
  69. data/lib/karafka/pro/routing/features/expiring/config.rb +27 -0
  70. data/lib/karafka/pro/routing/features/expiring/contract.rb +38 -0
  71. data/lib/karafka/pro/routing/features/expiring/topic.rb +59 -0
  72. data/lib/karafka/pro/routing/features/expiring.rb +27 -0
  73. data/lib/karafka/pro/routing/features/filtering/config.rb +40 -0
  74. data/lib/karafka/pro/routing/features/filtering/contract.rb +41 -0
  75. data/lib/karafka/pro/routing/features/filtering/topic.rb +51 -0
  76. data/lib/karafka/pro/routing/features/filtering.rb +27 -0
  77. data/lib/karafka/pro/routing/features/long_running_job/contract.rb +1 -1
  78. data/lib/karafka/pro/routing/features/throttling/config.rb +32 -0
  79. data/lib/karafka/pro/routing/features/throttling/contract.rb +41 -0
  80. data/lib/karafka/pro/routing/features/throttling/topic.rb +69 -0
  81. data/lib/karafka/pro/routing/features/throttling.rb +30 -0
  82. data/lib/karafka/processing/coordinator.rb +60 -30
  83. data/lib/karafka/processing/coordinators_buffer.rb +5 -1
  84. data/lib/karafka/processing/executor.rb +23 -16
  85. data/lib/karafka/processing/executors_buffer.rb +10 -26
  86. data/lib/karafka/processing/jobs/consume.rb +2 -4
  87. data/lib/karafka/processing/jobs/idle.rb +24 -0
  88. data/lib/karafka/processing/jobs_builder.rb +2 -3
  89. data/lib/karafka/processing/result.rb +5 -0
  90. data/lib/karafka/processing/strategies/aj_dlq_mom.rb +1 -1
  91. data/lib/karafka/processing/strategies/base.rb +5 -0
  92. data/lib/karafka/processing/strategies/default.rb +50 -0
  93. data/lib/karafka/processing/strategies/dlq.rb +13 -4
  94. data/lib/karafka/processing/strategies/dlq_mom.rb +8 -3
  95. data/lib/karafka/processing/strategy_selector.rb +27 -10
  96. data/lib/karafka/version.rb +1 -1
  97. data/renovate.json +6 -0
  98. data.tar.gz.sig +0 -0
  99. metadata +66 -22
  100. metadata.gz.sig +0 -0
  101. data/lib/karafka/pro/processing/strategies/aj_dlq_lrj_mom.rb +0 -42
  102. data/lib/karafka/pro/processing/strategies/aj_dlq_lrj_mom_vp.rb +0 -70
  103. data/lib/karafka/pro/processing/strategies/aj_dlq_mom.rb +0 -62
  104. data/lib/karafka/pro/processing/strategies/aj_dlq_mom_vp.rb +0 -68
  105. data/lib/karafka/pro/processing/strategies/aj_lrj_mom_vp.rb +0 -75
  106. data/lib/karafka/pro/processing/strategies/aj_mom_vp.rb +0 -62
  107. data/lib/karafka/pro/processing/strategies/dlq.rb +0 -120
  108. data/lib/karafka/pro/processing/strategies/dlq_lrj.rb +0 -65
  109. data/lib/karafka/pro/processing/strategies/dlq_lrj_mom.rb +0 -62
  110. data/lib/karafka/pro/processing/strategies/dlq_mom.rb +0 -62
  111. data/lib/karafka/pro/processing/strategies/dlq_vp.rb +0 -37
  112. data/lib/karafka/pro/processing/strategies/lrj.rb +0 -83
  113. data/lib/karafka/pro/processing/strategies/lrj_mom.rb +0 -73
@@ -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
- # Dead-Letter Queue enabled
19
- # Long-Running Job enabled
20
- # Virtual Partitions enabled
21
- module DlqLrjVp
22
- # Same flow as the Dlq Lrj because VP collapses on errors, so DlqLrj can kick in
23
- include Vp
24
- include DlqLrj
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
- # Features for this strategy
27
- FEATURES = %i[
28
- dead_letter_queue
29
- long_running_job
30
- virtual_partitions
31
- ].freeze
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