karafka 2.0.15 → 2.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +2 -1
  4. data/.rspec +2 -0
  5. data/CHANGELOG.md +98 -0
  6. data/Gemfile.lock +14 -14
  7. data/LICENSE +1 -1
  8. data/README.md +4 -1
  9. data/bin/integrations +3 -2
  10. data/bin/rspecs +4 -0
  11. data/config/errors.yml +10 -4
  12. data/lib/active_job/karafka.rb +0 -6
  13. data/lib/karafka/active_job/consumer.rb +1 -0
  14. data/lib/karafka/admin.rb +2 -2
  15. data/lib/karafka/base_consumer.rb +31 -21
  16. data/lib/karafka/connection/listener.rb +6 -4
  17. data/lib/karafka/contracts/consumer_group.rb +0 -14
  18. data/lib/karafka/contracts/{consumer_group_topic.rb → topic.rb} +2 -3
  19. data/lib/karafka/errors.rb +6 -4
  20. data/lib/karafka/instrumentation/logger_listener.rb +25 -11
  21. data/lib/karafka/instrumentation/notifications.rb +2 -0
  22. data/lib/karafka/instrumentation/vendors/datadog/dashboard.json +1 -1
  23. data/lib/karafka/instrumentation/vendors/datadog/listener.rb +37 -32
  24. data/lib/karafka/instrumentation/vendors/datadog/logger_listener.rb +153 -0
  25. data/lib/karafka/pro/active_job/consumer.rb +3 -1
  26. data/lib/karafka/pro/active_job/dispatcher.rb +3 -1
  27. data/lib/karafka/pro/active_job/job_options_contract.rb +3 -1
  28. data/lib/karafka/pro/base_consumer.rb +3 -85
  29. data/lib/karafka/pro/loader.rb +31 -24
  30. data/lib/karafka/pro/performance_tracker.rb +3 -1
  31. data/lib/karafka/pro/processing/coordinator.rb +16 -1
  32. data/lib/karafka/pro/processing/jobs/consume_non_blocking.rb +3 -1
  33. data/lib/karafka/pro/processing/jobs_builder.rb +3 -1
  34. data/lib/karafka/pro/processing/partitioner.rb +3 -1
  35. data/lib/karafka/pro/processing/scheduler.rb +3 -1
  36. data/lib/karafka/pro/processing/strategies/aj_dlq_lrj_mom.rb +40 -0
  37. data/lib/karafka/pro/processing/strategies/aj_dlq_mom.rb +62 -0
  38. data/lib/karafka/pro/processing/strategies/aj_lrj_mom.rb +35 -0
  39. data/lib/karafka/pro/processing/strategies/aj_lrj_mom_vp.rb +69 -0
  40. data/lib/karafka/pro/processing/strategies/aj_mom.rb +33 -0
  41. data/lib/karafka/pro/processing/strategies/aj_mom_vp.rb +58 -0
  42. data/lib/karafka/pro/processing/strategies/base.rb +26 -0
  43. data/lib/karafka/pro/processing/strategies/default.rb +69 -0
  44. data/lib/karafka/pro/processing/strategies/dlq.rb +88 -0
  45. data/lib/karafka/pro/processing/strategies/dlq_lrj.rb +64 -0
  46. data/lib/karafka/pro/processing/strategies/dlq_lrj_mom.rb +60 -0
  47. data/lib/karafka/pro/processing/strategies/dlq_mom.rb +58 -0
  48. data/lib/karafka/pro/processing/strategies/lrj.rb +76 -0
  49. data/lib/karafka/pro/processing/strategies/lrj_mom.rb +68 -0
  50. data/lib/karafka/pro/processing/strategies/lrj_vp.rb +33 -0
  51. data/lib/karafka/pro/processing/strategies/mom.rb +43 -0
  52. data/lib/karafka/pro/processing/strategies/vp.rb +32 -0
  53. data/lib/karafka/pro/processing/strategy_selector.rb +58 -0
  54. data/lib/karafka/pro/{contracts → routing/features}/base.rb +8 -5
  55. data/lib/karafka/pro/routing/features/dead_letter_queue/contract.rb +49 -0
  56. data/lib/karafka/pro/routing/{builder_extensions.rb → features/dead_letter_queue.rb} +9 -12
  57. data/lib/karafka/pro/routing/features/long_running_job/config.rb +28 -0
  58. data/lib/karafka/pro/routing/features/long_running_job/contract.rb +37 -0
  59. data/lib/karafka/pro/routing/features/long_running_job/topic.rb +42 -0
  60. data/lib/karafka/pro/routing/features/long_running_job.rb +28 -0
  61. data/lib/karafka/pro/routing/features/virtual_partitions/config.rb +30 -0
  62. data/lib/karafka/pro/routing/features/virtual_partitions/contract.rb +69 -0
  63. data/lib/karafka/pro/routing/features/virtual_partitions/topic.rb +56 -0
  64. data/lib/karafka/pro/routing/features/virtual_partitions.rb +27 -0
  65. data/lib/karafka/processing/coordinator.rb +1 -1
  66. data/lib/karafka/processing/executor.rb +6 -0
  67. data/lib/karafka/processing/strategies/aj_dlq_mom.rb +44 -0
  68. data/lib/karafka/processing/strategies/aj_mom.rb +21 -0
  69. data/lib/karafka/processing/strategies/base.rb +37 -0
  70. data/lib/karafka/processing/strategies/default.rb +52 -0
  71. data/lib/karafka/processing/strategies/dlq.rb +77 -0
  72. data/lib/karafka/processing/strategies/dlq_mom.rb +42 -0
  73. data/lib/karafka/processing/strategies/mom.rb +29 -0
  74. data/lib/karafka/processing/strategy_selector.rb +30 -0
  75. data/lib/karafka/railtie.rb +9 -8
  76. data/lib/karafka/routing/builder.rb +6 -0
  77. data/lib/karafka/routing/features/active_job/builder.rb +33 -0
  78. data/lib/karafka/routing/features/active_job/config.rb +15 -0
  79. data/lib/karafka/routing/features/active_job/contract.rb +41 -0
  80. data/lib/karafka/routing/features/active_job/topic.rb +33 -0
  81. data/lib/karafka/routing/features/active_job.rb +13 -0
  82. data/lib/karafka/routing/features/base/expander.rb +53 -0
  83. data/lib/karafka/routing/features/base.rb +34 -0
  84. data/lib/karafka/routing/features/dead_letter_queue/config.rb +19 -0
  85. data/lib/karafka/routing/features/dead_letter_queue/contract.rb +40 -0
  86. data/lib/karafka/routing/features/dead_letter_queue/topic.rb +40 -0
  87. data/lib/karafka/routing/features/dead_letter_queue.rb +16 -0
  88. data/lib/karafka/routing/features/manual_offset_management/config.rb +15 -0
  89. data/lib/karafka/routing/features/manual_offset_management/contract.rb +24 -0
  90. data/lib/karafka/routing/features/manual_offset_management/topic.rb +35 -0
  91. data/lib/karafka/routing/features/manual_offset_management.rb +18 -0
  92. data/lib/karafka/routing/topic.rb +2 -10
  93. data/lib/karafka/server.rb +4 -2
  94. data/lib/karafka/setup/attributes_map.rb +5 -0
  95. data/lib/karafka/setup/config.rb +4 -4
  96. data/lib/karafka/time_trackers/pause.rb +21 -12
  97. data/lib/karafka/version.rb +1 -1
  98. data/lib/karafka.rb +7 -11
  99. data.tar.gz.sig +0 -0
  100. metadata +57 -9
  101. metadata.gz.sig +0 -0
  102. data/lib/karafka/active_job/routing/extensions.rb +0 -33
  103. data/lib/karafka/pro/contracts/consumer_group.rb +0 -34
  104. data/lib/karafka/pro/contracts/consumer_group_topic.rb +0 -69
  105. data/lib/karafka/pro/routing/topic_extensions.rb +0 -74
@@ -0,0 +1,60 @@
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
+ # Strategy for supporting DLQ with Mom and LRJ enabled
19
+ module DlqLrjMom
20
+ # This strategy needs to pause and revoke same way as DlqLrj but without the offset
21
+ # management
22
+ include DlqLrj
23
+
24
+ # Features for this strategy
25
+ FEATURES = %i[
26
+ dead_letter_queue
27
+ long_running_job
28
+ manual_offset_management
29
+ ].freeze
30
+
31
+ # LRJ standard flow after consumption with DLQ dispatch and no offset management
32
+ def handle_after_consume
33
+ coordinator.on_finished do
34
+ if coordinator.success?
35
+ coordinator.pause_tracker.reset
36
+
37
+ seek(coordinator.seek_offset) unless revoked?
38
+
39
+ resume
40
+ elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
41
+ pause(coordinator.seek_offset)
42
+ else
43
+ coordinator.pause_tracker.reset
44
+
45
+ skippable_message = find_skippable_message
46
+
47
+ unless revoked?
48
+ dispatch_to_dlq(skippable_message)
49
+ seek(coordinator.seek_offset)
50
+ end
51
+
52
+ resume
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ 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
+ # Strategy for supporting DLQ with Mom enabled
19
+ module DlqMom
20
+ # The broken message lookup is the same in this scenario
21
+ include Dlq
22
+
23
+ # Features for this strategy
24
+ FEATURES = %i[
25
+ dead_letter_queue
26
+ manual_offset_management
27
+ ].freeze
28
+
29
+ # When manual offset management is on, we do not mark anything as consumed automatically
30
+ # and we rely on the user to figure things out
31
+ def handle_after_consume
32
+ coordinator.on_finished do
33
+ return if revoked?
34
+
35
+ if coordinator.success?
36
+ coordinator.pause_tracker.reset
37
+ elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
38
+ pause(coordinator.seek_offset)
39
+ # If we've reached number of retries that we could, we need to skip the first message
40
+ # that was not marked as consumed, pause and continue, while also moving this message
41
+ # to the dead topic.
42
+ #
43
+ # For a Mom setup, this means, that user has to manage the checkpointing by himself.
44
+ # If no checkpointing is ever done, we end up with an endless loop.
45
+ else
46
+ # We reset the pause to indicate we will now consider it as "ok".
47
+ coordinator.pause_tracker.reset
48
+ skippable_message = find_skippable_message
49
+ dispatch_to_dlq(skippable_message)
50
+ pause(coordinator.seek_offset)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,76 @@
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
+ # Long-Running Job enabled
19
+ module Lrj
20
+ include Default
21
+
22
+ # Pause for tops 31 years
23
+ MAX_PAUSE_TIME = 1_000_000_000_000
24
+
25
+ # Features for this strategy
26
+ FEATURES = %i[
27
+ long_running_job
28
+ ].freeze
29
+
30
+ # We always need to pause prior to doing any jobs for LRJ
31
+ def handle_before_enqueue
32
+ # This ensures that when running LRJ with VP, things operate as expected run only once
33
+ # for all the virtual partitions collectively
34
+ coordinator.on_enqueued do
35
+ # Pause at the first message in a batch. That way in case of a crash, we will not
36
+ # loose any messages.
37
+ #
38
+ # For VP it applies the same way and since VP cannot be used with MOM we should not
39
+ # have any edge cases here.
40
+ pause(coordinator.seek_offset, MAX_PAUSE_TIME)
41
+ end
42
+ end
43
+
44
+ # LRJ standard flow after consumption
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 will
57
+ # cause the processing to keep going after the error backoff
58
+ pause(coordinator.seek_offset)
59
+ end
60
+ end
61
+ end
62
+
63
+ # We do not un-pause on revokations for LRJ
64
+ def handle_revoked
65
+ coordinator.on_revoked do
66
+ # We do not want to resume on revocation in case of a LRJ.
67
+ # For LRJ we resume after the successful processing or do a backoff pause in case of
68
+ # a failure. Double non-blocking resume could cause problems in coordination.
69
+ coordinator.revoke
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ 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
+ # Long-Running Job enabled
19
+ # Manual offset management enabled
20
+ module LrjMom
21
+ include Default
22
+
23
+ # Features for this strategy
24
+ FEATURES = %i[
25
+ long_running_job
26
+ manual_offset_management
27
+ ].freeze
28
+
29
+ # We always need to pause prior to doing any jobs for LRJ
30
+ def handle_before_enqueue
31
+ # This ensures that when running LRJ with VP, things operate as expected run only once
32
+ # for all the virtual partitions collectively
33
+ coordinator.on_enqueued do
34
+ # Pause at the first message in a batch. That way in case of a crash, we will not
35
+ # loose any messages.
36
+ #
37
+ # For VP it applies the same way and since VP cannot be used with MOM we should not
38
+ # have any edge cases here.
39
+ pause(coordinator.seek_offset, Lrj::MAX_PAUSE_TIME)
40
+ end
41
+ end
42
+
43
+ # No offset management, aside from that typical LRJ
44
+ def handle_after_consume
45
+ coordinator.on_finished do
46
+ if coordinator.success?
47
+ coordinator.pause_tracker.reset
48
+
49
+ seek(coordinator.seek_offset) unless revoked?
50
+
51
+ resume
52
+ else
53
+ pause(coordinator.seek_offset)
54
+ end
55
+ end
56
+ end
57
+
58
+ # We do not un-pause on revokations for LRJ
59
+ def handle_revoked
60
+ coordinator.on_revoked do
61
+ coordinator.revoke
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,33 @@
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
+ # Long-Running Job enabled
19
+ # Virtual Partitions enabled
20
+ module LrjVp
21
+ # Same flow as the standard Lrj
22
+ include Lrj
23
+
24
+ # Features for this strategy
25
+ FEATURES = %i[
26
+ long_running_job
27
+ virtual_partitions
28
+ ].freeze
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,43 @@
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
+ # Manual offset management enabled
19
+ module Mom
20
+ include Default
21
+
22
+ # Features for this strategy
23
+ FEATURES = %i[
24
+ manual_offset_management
25
+ ].freeze
26
+
27
+ # When mom is enabled, we do not mark messages as consumed after processing
28
+ def handle_after_consume
29
+ coordinator.on_finished do
30
+ return if revoked?
31
+
32
+ if coordinator.success?
33
+ coordinator.pause_tracker.reset
34
+ else
35
+ pause(coordinator.seek_offset)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,32 @@
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
+ # Just Virtual Partitions enabled
19
+ module Vp
20
+ # This flow is exactly the same as the default one because the default one is wrapper
21
+ # with `coordinator#on_finished`
22
+ include Default
23
+
24
+ # Features for this strategy
25
+ FEATURES = %i[
26
+ virtual_partitions
27
+ ].freeze
28
+ end
29
+ end
30
+ end
31
+ end
32
+ 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
+ # Selector of appropriate processing strategy matching topic combinations
18
+ # When using Karafka Pro, there is a different set of strategies than for regular, as there
19
+ # are different features.
20
+ class StrategySelector
21
+ def initialize
22
+ # We load them once for performance reasons not to do too many lookups
23
+ @available_strategies = Strategies
24
+ .constants
25
+ .delete_if { |k| k == :Base }
26
+ .map { |k| Strategies.const_get(k) }
27
+ end
28
+
29
+ # @param topic [Karafka::Routing::Topic] topic with settings based on which we find
30
+ # the strategy
31
+ # @return [Module] module with proper strategy
32
+ def find(topic)
33
+ feature_set = features_map(topic)
34
+
35
+ @available_strategies.find do |strategy|
36
+ strategy::FEATURES.sort == feature_set
37
+ end || raise(Errors::StrategyNotFoundError, topic.name)
38
+ end
39
+
40
+ private
41
+
42
+ # Builds features map used to find matching processing strategy
43
+ #
44
+ # @param topic [Karafka::Routing::Topic]
45
+ # @return [Array<Symbol>]
46
+ def features_map(topic)
47
+ [
48
+ topic.active_job? ? :active_job : nil,
49
+ topic.long_running_job? ? :long_running_job : nil,
50
+ topic.manual_offset_management? ? :manual_offset_management : nil,
51
+ topic.virtual_partitions? ? :virtual_partitions : nil,
52
+ topic.dead_letter_queue? ? :dead_letter_queue : nil
53
+ ].compact.sort
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This Karafka component is a Pro component.
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
4
6
  # All of the commercial components are present in the lib/karafka/pro directory of this
5
7
  # repository and their usage requires commercial license agreement.
6
8
  #
@@ -11,10 +13,11 @@
11
13
 
12
14
  module Karafka
13
15
  module Pro
14
- # Namespace for Karafka Pro related contracts
15
- module Contracts
16
- # Base contract for Pro components contracts
17
- class Base < ::Karafka::Contracts::Base
16
+ module Routing
17
+ module Features
18
+ # Base class for all the Pro features
19
+ class Base < Karafka::Routing::Features::Base
20
+ end
18
21
  end
19
22
  end
20
23
  end
@@ -0,0 +1,49 @@
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 Routing
17
+ module Features
18
+ class DeadLetterQueue < Base
19
+ # Extended rules for dead letter queue settings
20
+ class Contract < Contracts::Base
21
+ configure do |config|
22
+ config.error_messages = YAML.safe_load(
23
+ File.read(
24
+ File.join(Karafka.gem_root, 'config', 'errors.yml')
25
+ )
26
+ ).fetch('en').fetch('validations').fetch('pro_topic')
27
+ end
28
+
29
+ # Make sure that we don't use DLQ with VP
30
+ # Using those two would cause many issues because the offset within VP is not
31
+ # manageable so in scenarios where we would fail on the last message, we would move by
32
+ # one and try again and fail, and move by one and try again and fail and so on...
33
+ virtual do |data, errors|
34
+ next unless errors.empty?
35
+
36
+ dead_letter_queue = data[:dead_letter_queue]
37
+ virtual_partitions = data[:virtual_partitions]
38
+
39
+ next unless dead_letter_queue[:active]
40
+ next unless virtual_partitions[:active]
41
+
42
+ [[%i[dead_letter_queue], :not_with_virtual_partitions]]
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This Karafka component is a Pro component.
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
4
6
  # All of the commercial components are present in the lib/karafka/pro directory of this
5
7
  # repository and their usage requires commercial license agreement.
6
8
  #
@@ -11,18 +13,13 @@
11
13
 
12
14
  module Karafka
13
15
  module Pro
14
- # Pro routing components
15
16
  module Routing
16
- # Routing extensions for builder to be able to validate Pro components correct usage
17
- module BuilderExtensions
18
- # Validate consumer groups with pro contracts
19
- # @param block [Proc] routing defining block
20
- def draw(&block)
21
- super
22
-
23
- each do |consumer_group|
24
- ::Karafka::Pro::Contracts::ConsumerGroup.new.validate!(consumer_group.to_h)
25
- end
17
+ module Features
18
+ # Enhanced Dead Letter Queue
19
+ #
20
+ # This version behaves similar to the regular version but provides ordering warranties and
21
+ # allows for batch skipping
22
+ class DeadLetterQueue < Base
26
23
  end
27
24
  end
28
25
  end
@@ -0,0 +1,28 @@
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 Routing
17
+ module Features
18
+ class LongRunningJob < Base
19
+ # Long-Running Jobs configuration
20
+ Config = Struct.new(
21
+ :active,
22
+ keyword_init: true
23
+ ) { alias_method :active?, :active }
24
+ end
25
+ end
26
+ end
27
+ end
28
+ 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 Routing
17
+ module Features
18
+ class LongRunningJob < Base
19
+ # Rules around manual offset management settings
20
+ class Contract < Contracts::Base
21
+ configure do |config|
22
+ config.error_messages = YAML.safe_load(
23
+ File.read(
24
+ File.join(Karafka.gem_root, 'config', 'errors.yml')
25
+ )
26
+ ).fetch('en').fetch('validations').fetch('pro_topic')
27
+ end
28
+
29
+ nested(:long_running_job) do
30
+ required(:active) { |val| [true, false].include?(val) }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,42 @@
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 Routing
17
+ module Features
18
+ class LongRunningJob < Base
19
+ # Long-Running Jobs topic API extensions
20
+ module Topic
21
+ # @param active [Boolean] do we want to enable long-running job feature for this topic
22
+ def long_running_job(active = false)
23
+ @long_running_job ||= Config.new(active: active)
24
+ end
25
+
26
+ # @return [Boolean] is a given job on a topic a long-running one
27
+ def long_running_job?
28
+ long_running_job.active?
29
+ end
30
+
31
+ # @return [Hash] topic with all its native configuration options plus lrj
32
+ def to_h
33
+ super.merge(
34
+ long_running_job: long_running_job.to_h
35
+ ).freeze
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,28 @@
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
+ # Namespace for Pro routing enhancements
17
+ module Routing
18
+ # Namespace for additional Pro features
19
+ module Features
20
+ # Long-Running Jobs feature config and DSL namespace.
21
+ #
22
+ # Long-Running Jobs allow you to run Karafka jobs beyond `max.poll.interval.ms`
23
+ class LongRunningJob < Base
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end