karafka 2.0.40 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +2 -2
  4. data/CHANGELOG.md +30 -1
  5. data/Gemfile +3 -2
  6. data/Gemfile.lock +13 -1
  7. data/bin/integrations +17 -2
  8. data/config/locales/errors.yml +10 -0
  9. data/config/locales/pro_errors.yml +0 -2
  10. data/lib/karafka/active_job/consumer.rb +16 -11
  11. data/lib/karafka/active_job/current_attributes/loading.rb +36 -0
  12. data/lib/karafka/active_job/current_attributes/persistence.rb +28 -0
  13. data/lib/karafka/active_job/current_attributes.rb +42 -0
  14. data/lib/karafka/active_job/dispatcher.rb +8 -2
  15. data/lib/karafka/admin.rb +17 -13
  16. data/lib/karafka/connection/client.rb +6 -3
  17. data/lib/karafka/errors.rb +3 -0
  18. data/lib/karafka/instrumentation/callbacks/statistics.rb +12 -0
  19. data/lib/karafka/instrumentation/logger_listener.rb +16 -5
  20. data/lib/karafka/instrumentation/vendors/kubernetes/liveness_listener.rb +166 -0
  21. data/lib/karafka/pro/active_job/consumer.rb +1 -10
  22. data/lib/karafka/pro/active_job/dispatcher.rb +2 -2
  23. data/lib/karafka/pro/iterator.rb +253 -0
  24. data/lib/karafka/pro/processing/coordinator.rb +20 -1
  25. data/lib/karafka/pro/processing/filters/virtual_limiter.rb +52 -0
  26. data/lib/karafka/pro/processing/filters_applier.rb +4 -0
  27. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom_vp.rb +1 -1
  28. data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom.rb +3 -1
  29. data/lib/karafka/pro/processing/strategies/aj/dlq_mom_vp.rb +2 -2
  30. data/lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb +2 -0
  31. data/lib/karafka/pro/processing/strategies/aj/mom_vp.rb +1 -1
  32. data/lib/karafka/pro/processing/strategies/dlq/ftr.rb +1 -1
  33. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom.rb +3 -6
  34. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom_vp.rb +43 -0
  35. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_vp.rb +1 -0
  36. data/lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb +3 -7
  37. data/lib/karafka/pro/processing/strategies/dlq/ftr_mom_vp.rb +41 -0
  38. data/lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb +1 -0
  39. data/lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb +3 -6
  40. data/lib/karafka/pro/processing/strategies/dlq/lrj_mom_vp.rb +36 -0
  41. data/lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb +1 -0
  42. data/lib/karafka/pro/processing/strategies/dlq/mom.rb +8 -7
  43. data/lib/karafka/pro/processing/strategies/dlq/mom_vp.rb +37 -0
  44. data/lib/karafka/pro/processing/strategies/lrj/default.rb +2 -0
  45. data/lib/karafka/pro/processing/strategies/lrj/ftr_mom_vp.rb +40 -0
  46. data/lib/karafka/pro/processing/strategies/lrj/mom.rb +2 -0
  47. data/lib/karafka/pro/processing/strategies/lrj/mom_vp.rb +38 -0
  48. data/lib/karafka/pro/processing/strategies/mom/ftr_vp.rb +37 -0
  49. data/lib/karafka/pro/{base_consumer.rb → processing/strategies/mom/vp.rb} +17 -7
  50. data/lib/karafka/pro/processing/strategies/vp/default.rb +51 -0
  51. data/lib/karafka/pro/processing/virtual_offset_manager.rb +147 -0
  52. data/lib/karafka/pro/routing/features/virtual_partitions/contract.rb +0 -17
  53. data/lib/karafka/processing/strategies/default.rb +2 -0
  54. data/lib/karafka/processing/strategies/dlq_mom.rb +9 -7
  55. data/lib/karafka/routing/router.rb +15 -0
  56. data/lib/karafka/setup/config.rb +7 -1
  57. data/lib/karafka/version.rb +1 -1
  58. data/lib/karafka.rb +5 -0
  59. data.tar.gz.sig +0 -0
  60. metadata +17 -4
  61. metadata.gz.sig +0 -0
  62. data/lib/karafka/instrumentation/vendors/datadog/listener.rb +0 -16
@@ -29,16 +29,18 @@ module Karafka
29
29
  # We reset the pause to indicate we will now consider it as "ok".
30
30
  coordinator.pause_tracker.reset
31
31
 
32
- skippable_message, marked = find_skippable_message
32
+ skippable_message, = find_skippable_message
33
33
 
34
34
  dispatch_to_dlq(skippable_message)
35
35
 
36
- # Backoff and move forward
37
- if marked
38
- pause(coordinator.seek_offset, nil, false)
39
- else
40
- pause(skippable_message.offset + 1, nil, false)
41
- end
36
+ # Save the next offset we want to go with after moving given message to DLQ
37
+ # Without this, we would not be able to move forward and we would end up
38
+ # in an infinite loop trying to un-pause from the message we've already processed
39
+ # Of course, since it's a MoM a rebalance or kill, will move it back as no
40
+ # offsets are being committed
41
+ coordinator.seek_offset = skippable_message.offset + 1
42
+
43
+ pause(coordinator.seek_offset, nil, false)
42
44
  end
43
45
  end
44
46
  end
@@ -32,8 +32,23 @@ module Karafka
32
32
  nil
33
33
  end
34
34
 
35
+ # Finds the topic by name (in any consumer group) and if not present, will built a new
36
+ # representation of the topic with the defaults and default deserializer.
37
+ #
38
+ # This is used in places where we may operate on topics that are not part of the routing
39
+ # but we want to do something on them (display data, iterate over, etc)
40
+ # @param name [String] name of the topic we are looking for
41
+ # @return [Karafka::Routing::Topic]
42
+ #
43
+ # @note Please note, that in case of a new topic, it will have a newly built consumer group
44
+ # as well, that is not part of the routing.
45
+ def find_or_initialize_by_name(name)
46
+ find_by(name: name) || Topic.new(name, ConsumerGroup.new(name))
47
+ end
48
+
35
49
  module_function :find
36
50
  module_function :find_by
51
+ module_function :find_or_initialize_by_name
37
52
  end
38
53
  end
39
54
  end
@@ -18,7 +18,13 @@ module Karafka
18
18
  KAFKA_DEFAULTS = {
19
19
  # We emit the statistics by default, so all the instrumentation and web-ui work out of
20
20
  # the box, without requiring users to take any extra actions aside from enabling.
21
- 'statistics.interval.ms': 5_000
21
+ 'statistics.interval.ms': 5_000,
22
+ 'client.software.name': 'karafka',
23
+ 'client.software.version': [
24
+ "v#{Karafka::VERSION}",
25
+ "rdkafka-ruby-v#{Rdkafka::VERSION}",
26
+ "librdkafka-v#{Rdkafka::LIBRDKAFKA_VERSION}"
27
+ ].join('-')
22
28
  }.freeze
23
29
 
24
30
  # Contains settings that should not be used in production but make life easier in dev
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '2.0.40'
6
+ VERSION = '2.1.0'
7
7
  end
data/lib/karafka.rb CHANGED
@@ -114,6 +114,11 @@ end
114
114
  loader = Zeitwerk::Loader.for_gem
115
115
  # Do not load Rails extensions by default, this will be handled by Railtie if they are needed
116
116
  loader.ignore(Karafka.gem_root.join('lib/active_job'))
117
+ # Do not load CurrentAttributes components as they will be loaded if needed
118
+ # @note We have to exclude both the .rb file as well as the whole directory so users can require
119
+ # current attributes only when needed
120
+ loader.ignore(Karafka.gem_root.join('lib/karafka/active_job/current_attributes'))
121
+ loader.ignore(Karafka.gem_root.join('lib/karafka/active_job/current_attributes.rb'))
117
122
  # Do not load Railtie. It will load if after everything is ready, so we don't have to load any
118
123
  # Karafka components when we require this railtie. Railtie needs to be loaded last.
119
124
  loader.ignore(Karafka.gem_root.join('lib/karafka/railtie'))
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.40
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
36
36
  MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
37
37
  -----END CERTIFICATE-----
38
- date: 2023-04-13 00:00:00.000000000 Z
38
+ date: 2023-05-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka-core
@@ -156,6 +156,9 @@ files:
156
156
  - lib/active_job/queue_adapters/karafka_adapter.rb
157
157
  - lib/karafka.rb
158
158
  - lib/karafka/active_job/consumer.rb
159
+ - lib/karafka/active_job/current_attributes.rb
160
+ - lib/karafka/active_job/current_attributes/loading.rb
161
+ - lib/karafka/active_job/current_attributes/persistence.rb
159
162
  - lib/karafka/active_job/dispatcher.rb
160
163
  - lib/karafka/active_job/job_extensions.rb
161
164
  - lib/karafka/active_job/job_options_contract.rb
@@ -197,9 +200,9 @@ files:
197
200
  - lib/karafka/instrumentation/notifications.rb
198
201
  - lib/karafka/instrumentation/proctitle_listener.rb
199
202
  - lib/karafka/instrumentation/vendors/datadog/dashboard.json
200
- - lib/karafka/instrumentation/vendors/datadog/listener.rb
201
203
  - lib/karafka/instrumentation/vendors/datadog/logger_listener.rb
202
204
  - lib/karafka/instrumentation/vendors/datadog/metrics_listener.rb
205
+ - lib/karafka/instrumentation/vendors/kubernetes/liveness_listener.rb
203
206
  - lib/karafka/licenser.rb
204
207
  - lib/karafka/messages/batch_metadata.rb
205
208
  - lib/karafka/messages/builders/batch_metadata.rb
@@ -216,7 +219,6 @@ files:
216
219
  - lib/karafka/pro/active_job/consumer.rb
217
220
  - lib/karafka/pro/active_job/dispatcher.rb
218
221
  - lib/karafka/pro/active_job/job_options_contract.rb
219
- - lib/karafka/pro/base_consumer.rb
220
222
  - lib/karafka/pro/encryption.rb
221
223
  - lib/karafka/pro/encryption/cipher.rb
222
224
  - lib/karafka/pro/encryption/contracts/config.rb
@@ -224,6 +226,7 @@ files:
224
226
  - lib/karafka/pro/encryption/messages/middleware.rb
225
227
  - lib/karafka/pro/encryption/messages/parser.rb
226
228
  - lib/karafka/pro/encryption/setup/config.rb
229
+ - lib/karafka/pro/iterator.rb
227
230
  - lib/karafka/pro/loader.rb
228
231
  - lib/karafka/pro/performance_tracker.rb
229
232
  - lib/karafka/pro/processing/collapser.rb
@@ -232,6 +235,7 @@ files:
232
235
  - lib/karafka/pro/processing/filters/delayer.rb
233
236
  - lib/karafka/pro/processing/filters/expirer.rb
234
237
  - lib/karafka/pro/processing/filters/throttler.rb
238
+ - lib/karafka/pro/processing/filters/virtual_limiter.rb
235
239
  - lib/karafka/pro/processing/filters_applier.rb
236
240
  - lib/karafka/pro/processing/jobs/consume_non_blocking.rb
237
241
  - lib/karafka/pro/processing/jobs/revoked_non_blocking.rb
@@ -261,26 +265,35 @@ files:
261
265
  - lib/karafka/pro/processing/strategies/dlq/ftr.rb
262
266
  - lib/karafka/pro/processing/strategies/dlq/ftr_lrj.rb
263
267
  - lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom.rb
268
+ - lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom_vp.rb
264
269
  - lib/karafka/pro/processing/strategies/dlq/ftr_lrj_vp.rb
265
270
  - lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb
271
+ - lib/karafka/pro/processing/strategies/dlq/ftr_mom_vp.rb
266
272
  - lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb
267
273
  - lib/karafka/pro/processing/strategies/dlq/lrj.rb
268
274
  - lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb
275
+ - lib/karafka/pro/processing/strategies/dlq/lrj_mom_vp.rb
269
276
  - lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb
270
277
  - lib/karafka/pro/processing/strategies/dlq/mom.rb
278
+ - lib/karafka/pro/processing/strategies/dlq/mom_vp.rb
271
279
  - lib/karafka/pro/processing/strategies/dlq/vp.rb
272
280
  - lib/karafka/pro/processing/strategies/ftr/default.rb
273
281
  - lib/karafka/pro/processing/strategies/ftr/vp.rb
274
282
  - lib/karafka/pro/processing/strategies/lrj/default.rb
275
283
  - lib/karafka/pro/processing/strategies/lrj/ftr.rb
276
284
  - lib/karafka/pro/processing/strategies/lrj/ftr_mom.rb
285
+ - lib/karafka/pro/processing/strategies/lrj/ftr_mom_vp.rb
277
286
  - lib/karafka/pro/processing/strategies/lrj/ftr_vp.rb
278
287
  - lib/karafka/pro/processing/strategies/lrj/mom.rb
288
+ - lib/karafka/pro/processing/strategies/lrj/mom_vp.rb
279
289
  - lib/karafka/pro/processing/strategies/lrj/vp.rb
280
290
  - lib/karafka/pro/processing/strategies/mom/default.rb
281
291
  - lib/karafka/pro/processing/strategies/mom/ftr.rb
292
+ - lib/karafka/pro/processing/strategies/mom/ftr_vp.rb
293
+ - lib/karafka/pro/processing/strategies/mom/vp.rb
282
294
  - lib/karafka/pro/processing/strategies/vp/default.rb
283
295
  - lib/karafka/pro/processing/strategy_selector.rb
296
+ - lib/karafka/pro/processing/virtual_offset_manager.rb
284
297
  - lib/karafka/pro/routing/features/base.rb
285
298
  - lib/karafka/pro/routing/features/dead_letter_queue.rb
286
299
  - lib/karafka/pro/routing/features/dead_letter_queue/contract.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'metrics_listener'
4
-
5
- module Karafka
6
- module Instrumentation
7
- # Namespace for vendor specific instrumentation
8
- module Vendors
9
- # Datadog specific instrumentation
10
- module Datadog
11
- # Alias to keep backwards compatibility
12
- Listener = MetricsListener
13
- end
14
- end
15
- end
16
- end