karafka 2.2.14 → 2.3.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +38 -12
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +23 -0
  6. data/Gemfile.lock +12 -12
  7. data/README.md +0 -2
  8. data/SECURITY.md +23 -0
  9. data/config/locales/errors.yml +7 -1
  10. data/config/locales/pro_errors.yml +22 -0
  11. data/docker-compose.yml +1 -1
  12. data/karafka.gemspec +2 -2
  13. data/lib/karafka/admin/acl.rb +287 -0
  14. data/lib/karafka/admin.rb +9 -13
  15. data/lib/karafka/app.rb +5 -3
  16. data/lib/karafka/base_consumer.rb +9 -1
  17. data/lib/karafka/cli/base.rb +1 -1
  18. data/lib/karafka/connection/client.rb +83 -76
  19. data/lib/karafka/connection/conductor.rb +28 -0
  20. data/lib/karafka/connection/listener.rb +159 -42
  21. data/lib/karafka/connection/listeners_batch.rb +5 -11
  22. data/lib/karafka/connection/manager.rb +72 -0
  23. data/lib/karafka/connection/messages_buffer.rb +12 -0
  24. data/lib/karafka/connection/proxy.rb +17 -0
  25. data/lib/karafka/connection/status.rb +75 -0
  26. data/lib/karafka/contracts/config.rb +14 -10
  27. data/lib/karafka/contracts/consumer_group.rb +9 -1
  28. data/lib/karafka/contracts/topic.rb +3 -1
  29. data/lib/karafka/errors.rb +13 -0
  30. data/lib/karafka/instrumentation/logger_listener.rb +3 -0
  31. data/lib/karafka/instrumentation/notifications.rb +13 -5
  32. data/lib/karafka/instrumentation/vendors/appsignal/metrics_listener.rb +31 -28
  33. data/lib/karafka/instrumentation/vendors/datadog/logger_listener.rb +20 -1
  34. data/lib/karafka/instrumentation/vendors/datadog/metrics_listener.rb +15 -12
  35. data/lib/karafka/instrumentation/vendors/kubernetes/liveness_listener.rb +39 -36
  36. data/lib/karafka/pro/base_consumer.rb +47 -0
  37. data/lib/karafka/pro/connection/manager.rb +300 -0
  38. data/lib/karafka/pro/connection/multiplexing/listener.rb +40 -0
  39. data/lib/karafka/pro/iterator/tpl_builder.rb +1 -1
  40. data/lib/karafka/pro/iterator.rb +1 -6
  41. data/lib/karafka/pro/loader.rb +14 -0
  42. data/lib/karafka/pro/processing/coordinator.rb +2 -1
  43. data/lib/karafka/pro/processing/executor.rb +37 -0
  44. data/lib/karafka/pro/processing/expansions_selector.rb +32 -0
  45. data/lib/karafka/pro/processing/jobs/periodic.rb +41 -0
  46. data/lib/karafka/pro/processing/jobs/periodic_non_blocking.rb +32 -0
  47. data/lib/karafka/pro/processing/jobs_builder.rb +14 -3
  48. data/lib/karafka/pro/processing/offset_metadata/consumer.rb +44 -0
  49. data/lib/karafka/pro/processing/offset_metadata/fetcher.rb +131 -0
  50. data/lib/karafka/pro/processing/offset_metadata/listener.rb +46 -0
  51. data/lib/karafka/pro/processing/schedulers/base.rb +39 -23
  52. data/lib/karafka/pro/processing/schedulers/default.rb +12 -14
  53. data/lib/karafka/pro/processing/strategies/default.rb +134 -1
  54. data/lib/karafka/pro/processing/strategies/dlq/default.rb +35 -0
  55. data/lib/karafka/pro/processing/strategies/vp/default.rb +59 -25
  56. data/lib/karafka/pro/processing/virtual_offset_manager.rb +41 -11
  57. data/lib/karafka/pro/routing/features/long_running_job/topic.rb +2 -0
  58. data/lib/karafka/pro/routing/features/multiplexing/config.rb +38 -0
  59. data/lib/karafka/pro/routing/features/multiplexing/contracts/topic.rb +114 -0
  60. data/lib/karafka/pro/routing/features/multiplexing/patches/contracts/consumer_group.rb +42 -0
  61. data/lib/karafka/pro/routing/features/multiplexing/proxy.rb +38 -0
  62. data/lib/karafka/pro/routing/features/multiplexing/subscription_group.rb +42 -0
  63. data/lib/karafka/pro/routing/features/multiplexing/subscription_groups_builder.rb +40 -0
  64. data/lib/karafka/pro/routing/features/multiplexing.rb +59 -0
  65. data/lib/karafka/pro/routing/features/non_blocking_job/topic.rb +32 -0
  66. data/lib/karafka/pro/routing/features/non_blocking_job.rb +37 -0
  67. data/lib/karafka/pro/routing/features/offset_metadata/config.rb +33 -0
  68. data/lib/karafka/pro/routing/features/offset_metadata/contracts/topic.rb +42 -0
  69. data/lib/karafka/pro/routing/features/offset_metadata/topic.rb +65 -0
  70. data/lib/karafka/pro/routing/features/offset_metadata.rb +40 -0
  71. data/lib/karafka/pro/routing/features/patterns/contracts/consumer_group.rb +4 -0
  72. data/lib/karafka/pro/routing/features/patterns/detector.rb +18 -10
  73. data/lib/karafka/pro/routing/features/periodic_job/config.rb +37 -0
  74. data/lib/karafka/pro/routing/features/periodic_job/contracts/topic.rb +44 -0
  75. data/lib/karafka/pro/routing/features/periodic_job/topic.rb +94 -0
  76. data/lib/karafka/pro/routing/features/periodic_job.rb +27 -0
  77. data/lib/karafka/pro/routing/features/virtual_partitions/config.rb +1 -0
  78. data/lib/karafka/pro/routing/features/virtual_partitions/contracts/topic.rb +1 -0
  79. data/lib/karafka/pro/routing/features/virtual_partitions/topic.rb +7 -2
  80. data/lib/karafka/process.rb +5 -3
  81. data/lib/karafka/processing/coordinator.rb +5 -1
  82. data/lib/karafka/processing/executor.rb +16 -10
  83. data/lib/karafka/processing/executors_buffer.rb +19 -4
  84. data/lib/karafka/processing/schedulers/default.rb +3 -2
  85. data/lib/karafka/processing/strategies/default.rb +6 -0
  86. data/lib/karafka/processing/strategies/dlq.rb +36 -0
  87. data/lib/karafka/routing/builder.rb +12 -2
  88. data/lib/karafka/routing/consumer_group.rb +5 -5
  89. data/lib/karafka/routing/features/base.rb +44 -8
  90. data/lib/karafka/routing/features/dead_letter_queue/config.rb +6 -1
  91. data/lib/karafka/routing/features/dead_letter_queue/contracts/topic.rb +1 -0
  92. data/lib/karafka/routing/features/dead_letter_queue/topic.rb +9 -2
  93. data/lib/karafka/routing/subscription_group.rb +2 -2
  94. data/lib/karafka/routing/subscription_groups_builder.rb +11 -2
  95. data/lib/karafka/routing/topic.rb +8 -10
  96. data/lib/karafka/runner.rb +13 -3
  97. data/lib/karafka/server.rb +5 -9
  98. data/lib/karafka/setup/config.rb +17 -0
  99. data/lib/karafka/status.rb +23 -14
  100. data/lib/karafka/templates/karafka.rb.erb +7 -0
  101. data/lib/karafka/time_trackers/partition_usage.rb +56 -0
  102. data/lib/karafka/version.rb +1 -1
  103. data.tar.gz.sig +0 -0
  104. metadata +42 -10
  105. metadata.gz.sig +0 -0
  106. data/lib/karafka/connection/consumer_group_coordinator.rb +0 -48
@@ -184,8 +184,23 @@ module Karafka
184
184
 
185
185
  # Namespace for internal connection related settings
186
186
  setting :connection do
187
+ # Manages starting up and stopping Kafka connections
188
+ setting :manager, default: Connection::Manager.new
189
+ # Controls frequency of connections management checks
190
+ setting :conductor, default: Connection::Conductor.new
191
+
187
192
  # Settings that are altered by our client proxy layer
188
193
  setting :proxy do
194
+ # Committed offsets for given CG query
195
+ setting :committed do
196
+ # timeout for this request. For busy or remote clusters, this should be high enough
197
+ setting :timeout, default: 5_000
198
+ # How many times should we try to run this call before raising an error
199
+ setting :max_attempts, default: 3
200
+ # How long should we wait before next attempt in case of a failure
201
+ setting :wait_time, default: 1_000
202
+ end
203
+
189
204
  # Watermark offsets request settings
190
205
  setting :query_watermark_offsets do
191
206
  # timeout for this request. For busy or remote clusters, this should be high enough
@@ -222,6 +237,8 @@ module Karafka
222
237
  setting :strategy_selector, default: Processing::StrategySelector.new
223
238
  # option expansions_selector [Object] processing expansions selector to be used
224
239
  setting :expansions_selector, default: Processing::ExpansionsSelector.new
240
+ # option [Class] executor class
241
+ setting :executor_class, default: Processing::Executor
225
242
  end
226
243
 
227
244
  # Things related to operating on messages
@@ -42,25 +42,34 @@ module Karafka
42
42
  end
43
43
 
44
44
  STATES.each do |state, transition|
45
- define_method :"#{state}?" do
46
- @status == state
47
- end
45
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
46
+ def #{state}?
47
+ @status == :#{state}
48
+ end
49
+
50
+ def #{transition}
51
+ MUTEX.synchronize do
52
+ # Do not allow reverse state transitions (we always go one way) or transition to the same
53
+ # state as currently
54
+ return if @status && STATES.keys.index(:#{state}) <= STATES.keys.index(@status)
48
55
 
49
- define_method transition do
50
- MUTEX.synchronize do
51
- # Do not allow reverse state transitions (we always go one way) or transition to the same
52
- # state as currently
53
- return if @status && STATES.keys.index(state) <= STATES.keys.index(@status)
56
+ @status = :#{state}
54
57
 
55
- @status = state
58
+ # Skip on creation (initializing)
59
+ # We skip as during this state we do not have yet a monitor
60
+ return if initializing?
56
61
 
57
- # Skip on creation (initializing)
58
- # We skip as during this state we do not have yet a monitor
59
- return if initializing?
62
+ # We do not set conductor in the initializer because this status object is created
63
+ # before the configuration kicks in
64
+ # We need to signal conductor on each state change as those may be relevant to
65
+ # listeners operations
66
+ @conductor ||= Karafka::App.config.internal.connection.conductor
67
+ @conductor.signal
60
68
 
61
- Karafka.monitor.instrument("app.#{state}")
69
+ Karafka.monitor.instrument("app.#{state}")
70
+ end
62
71
  end
63
- end
72
+ RUBY
64
73
  end
65
74
 
66
75
  # @return [Boolean] true if we are in any of the status that would indicate we should no longer
@@ -68,3 +68,10 @@ class KarafkaApp < Karafka::App
68
68
  end
69
69
  end
70
70
  end
71
+
72
+ # Karafka now features a Web UI!
73
+ # Visit the setup documentation to get started and enhance your experience.
74
+ #
75
+ # https://karafka.io/docs/Web-UI-Getting-Started
76
+ #
77
+ # Karafka::Web.enable!
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module TimeTrackers
5
+ # Tracker used to keep time reference when we last time dispatched any job related to a given
6
+ # topic partition.
7
+ #
8
+ # We can use it to know when last time a job was scheduled
9
+ #
10
+ # @note We do not track revocation as on revocation we clear given topic partition reference
11
+ # not to have a potential memory leak
12
+ #
13
+ # @note We do not track shutdown jobs as shutdown is finishing the process, so no time
14
+ # sensitive operations remain that would use this
15
+ #
16
+ # @note We consider partition as active if we scheduled any job related to it within the tick
17
+ # interval. This has nothing to do whether a partition is assigned.
18
+ class PartitionUsage < Base
19
+ # Creates new partition usage time tracker
20
+ def initialize
21
+ super
22
+
23
+ @last_usage = Hash.new do |topics_hash, topic_name|
24
+ topics_hash[topic_name] = Hash.new do |partitions_hash, partition_id|
25
+ partitions_hash[partition_id] = 0
26
+ end
27
+ end
28
+ end
29
+
30
+ # @param topic [String]
31
+ # @param partition [Integer]
32
+ # @param interval [Integer] minimum interval
33
+ # @return [Boolean] was this topic partition active
34
+ def active?(topic, partition, interval)
35
+ monotonic_now - @last_usage[topic][partition] < interval
36
+ end
37
+
38
+ # Marks usage of given partition
39
+ #
40
+ # @param topic [String]
41
+ # @param partition [Integer]
42
+ def track(topic, partition)
43
+ @last_usage[topic][partition] = monotonic_now
44
+ end
45
+
46
+ # Clears references about given partition. Useful on revocation so we do not store old
47
+ # unassigned partitions data
48
+ #
49
+ # @param topic [String]
50
+ # @param partition [Integer]
51
+ def revoke(topic, partition)
52
+ @last_usage[topic].delete(partition)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '2.2.14'
6
+ VERSION = '2.3.0.alpha1'
7
7
  end
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.2.14
4
+ version: 2.3.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
36
36
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
37
37
  -----END CERTIFICATE-----
38
- date: 2023-12-07 00:00:00.000000000 Z
38
+ date: 2024-01-15 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka-core
@@ -43,27 +43,27 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.2.7
46
+ version: 2.3.0.alpha1
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
- version: 2.3.0
49
+ version: 2.4.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.2.7
56
+ version: 2.3.0.alpha1
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
- version: 2.3.0
59
+ version: 2.4.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: waterdrop
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.6.11
66
+ version: 2.6.12
67
67
  - - "<"
68
68
  - !ruby/object:Gem::Version
69
69
  version: 3.0.0
@@ -73,7 +73,7 @@ dependencies:
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: 2.6.11
76
+ version: 2.6.12
77
77
  - - "<"
78
78
  - !ruby/object:Gem::Version
79
79
  version: 3.0.0
@@ -123,6 +123,7 @@ files:
123
123
  - LICENSE-COMM
124
124
  - LICENSE-LGPL
125
125
  - README.md
126
+ - SECURITY.md
126
127
  - bin/benchmarks
127
128
  - bin/create_token
128
129
  - bin/integrations
@@ -151,6 +152,7 @@ files:
151
152
  - lib/karafka/active_job/job_extensions.rb
152
153
  - lib/karafka/active_job/job_options_contract.rb
153
154
  - lib/karafka/admin.rb
155
+ - lib/karafka/admin/acl.rb
154
156
  - lib/karafka/app.rb
155
157
  - lib/karafka/base_consumer.rb
156
158
  - lib/karafka/cli.rb
@@ -162,14 +164,16 @@ files:
162
164
  - lib/karafka/cli/server.rb
163
165
  - lib/karafka/cli/topics.rb
164
166
  - lib/karafka/connection/client.rb
165
- - lib/karafka/connection/consumer_group_coordinator.rb
167
+ - lib/karafka/connection/conductor.rb
166
168
  - lib/karafka/connection/listener.rb
167
169
  - lib/karafka/connection/listeners_batch.rb
170
+ - lib/karafka/connection/manager.rb
168
171
  - lib/karafka/connection/messages_buffer.rb
169
172
  - lib/karafka/connection/pauses_manager.rb
170
173
  - lib/karafka/connection/proxy.rb
171
174
  - lib/karafka/connection/raw_messages_buffer.rb
172
175
  - lib/karafka/connection/rebalance_manager.rb
176
+ - lib/karafka/connection/status.rb
173
177
  - lib/karafka/contracts.rb
174
178
  - lib/karafka/contracts/base.rb
175
179
  - lib/karafka/contracts/config.rb
@@ -217,10 +221,13 @@ files:
217
221
  - lib/karafka/pro/active_job/consumer.rb
218
222
  - lib/karafka/pro/active_job/dispatcher.rb
219
223
  - lib/karafka/pro/active_job/job_options_contract.rb
224
+ - lib/karafka/pro/base_consumer.rb
220
225
  - lib/karafka/pro/cleaner.rb
221
226
  - lib/karafka/pro/cleaner/errors.rb
222
227
  - lib/karafka/pro/cleaner/messages/message.rb
223
228
  - lib/karafka/pro/cleaner/messages/messages.rb
229
+ - lib/karafka/pro/connection/manager.rb
230
+ - lib/karafka/pro/connection/multiplexing/listener.rb
224
231
  - lib/karafka/pro/contracts/base.rb
225
232
  - lib/karafka/pro/contracts/server_cli_options.rb
226
233
  - lib/karafka/pro/encryption.rb
@@ -237,6 +244,8 @@ files:
237
244
  - lib/karafka/pro/loader.rb
238
245
  - lib/karafka/pro/processing/collapser.rb
239
246
  - lib/karafka/pro/processing/coordinator.rb
247
+ - lib/karafka/pro/processing/executor.rb
248
+ - lib/karafka/pro/processing/expansions_selector.rb
240
249
  - lib/karafka/pro/processing/filters/base.rb
241
250
  - lib/karafka/pro/processing/filters/delayer.rb
242
251
  - lib/karafka/pro/processing/filters/expirer.rb
@@ -245,9 +254,14 @@ files:
245
254
  - lib/karafka/pro/processing/filters/virtual_limiter.rb
246
255
  - lib/karafka/pro/processing/filters_applier.rb
247
256
  - lib/karafka/pro/processing/jobs/consume_non_blocking.rb
257
+ - lib/karafka/pro/processing/jobs/periodic.rb
258
+ - lib/karafka/pro/processing/jobs/periodic_non_blocking.rb
248
259
  - lib/karafka/pro/processing/jobs/revoked_non_blocking.rb
249
260
  - lib/karafka/pro/processing/jobs_builder.rb
250
261
  - lib/karafka/pro/processing/jobs_queue.rb
262
+ - lib/karafka/pro/processing/offset_metadata/consumer.rb
263
+ - lib/karafka/pro/processing/offset_metadata/fetcher.rb
264
+ - lib/karafka/pro/processing/offset_metadata/listener.rb
251
265
  - lib/karafka/pro/processing/partitioner.rb
252
266
  - lib/karafka/pro/processing/schedulers/base.rb
253
267
  - lib/karafka/pro/processing/schedulers/default.rb
@@ -328,6 +342,19 @@ files:
328
342
  - lib/karafka/pro/routing/features/long_running_job/config.rb
329
343
  - lib/karafka/pro/routing/features/long_running_job/contracts/topic.rb
330
344
  - lib/karafka/pro/routing/features/long_running_job/topic.rb
345
+ - lib/karafka/pro/routing/features/multiplexing.rb
346
+ - lib/karafka/pro/routing/features/multiplexing/config.rb
347
+ - lib/karafka/pro/routing/features/multiplexing/contracts/topic.rb
348
+ - lib/karafka/pro/routing/features/multiplexing/patches/contracts/consumer_group.rb
349
+ - lib/karafka/pro/routing/features/multiplexing/proxy.rb
350
+ - lib/karafka/pro/routing/features/multiplexing/subscription_group.rb
351
+ - lib/karafka/pro/routing/features/multiplexing/subscription_groups_builder.rb
352
+ - lib/karafka/pro/routing/features/non_blocking_job.rb
353
+ - lib/karafka/pro/routing/features/non_blocking_job/topic.rb
354
+ - lib/karafka/pro/routing/features/offset_metadata.rb
355
+ - lib/karafka/pro/routing/features/offset_metadata/config.rb
356
+ - lib/karafka/pro/routing/features/offset_metadata/contracts/topic.rb
357
+ - lib/karafka/pro/routing/features/offset_metadata/topic.rb
331
358
  - lib/karafka/pro/routing/features/patterns.rb
332
359
  - lib/karafka/pro/routing/features/patterns/builder.rb
333
360
  - lib/karafka/pro/routing/features/patterns/config.rb
@@ -343,6 +370,10 @@ files:
343
370
  - lib/karafka/pro/routing/features/pausing.rb
344
371
  - lib/karafka/pro/routing/features/pausing/contracts/topic.rb
345
372
  - lib/karafka/pro/routing/features/pausing/topic.rb
373
+ - lib/karafka/pro/routing/features/periodic_job.rb
374
+ - lib/karafka/pro/routing/features/periodic_job/config.rb
375
+ - lib/karafka/pro/routing/features/periodic_job/contracts/topic.rb
376
+ - lib/karafka/pro/routing/features/periodic_job/topic.rb
346
377
  - lib/karafka/pro/routing/features/throttling.rb
347
378
  - lib/karafka/pro/routing/features/throttling/config.rb
348
379
  - lib/karafka/pro/routing/features/throttling/contracts/topic.rb
@@ -427,6 +458,7 @@ files:
427
458
  - lib/karafka/templates/example_consumer.rb.erb
428
459
  - lib/karafka/templates/karafka.rb.erb
429
460
  - lib/karafka/time_trackers/base.rb
461
+ - lib/karafka/time_trackers/partition_usage.rb
430
462
  - lib/karafka/time_trackers/pause.rb
431
463
  - lib/karafka/time_trackers/poll.rb
432
464
  - lib/karafka/version.rb
@@ -459,7 +491,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
459
491
  - !ruby/object:Gem::Version
460
492
  version: '0'
461
493
  requirements: []
462
- rubygems_version: 3.4.19
494
+ rubygems_version: 3.5.3
463
495
  signing_key:
464
496
  specification_version: 4
465
497
  summary: Karafka is Ruby and Rails efficient Kafka processing framework.
metadata.gz.sig CHANGED
Binary file
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Karafka
4
- module Connection
5
- # This object represents a collective status of execution of group of listeners running inside
6
- # of one consumer group but in separate subscription groups.
7
- #
8
- # There are cases when we do not want to close a given client when others from the same
9
- # consumer group are running because it can cause instabilities due to early shutdown of some
10
- # of the clients out of same consumer group.
11
- #
12
- # We also want to make sure, we close one consumer at a time while others can continue polling.
13
- #
14
- # This prevents a scenario, where a rebalance is not acknowledged and we loose assignment
15
- # without having a chance to commit changes.
16
- class ConsumerGroupCoordinator
17
- # @param group_size [Integer] number of separate subscription groups in a consumer group
18
- def initialize(group_size)
19
- @shutdown_mutex = Mutex.new
20
- @group_size = group_size
21
- @finished = Set.new
22
- end
23
-
24
- # @return [Boolean] true if all the subscription groups from a given consumer group are
25
- # finished
26
- def finished?
27
- @finished.size == @group_size
28
- end
29
-
30
- # @return [Boolean] can we start shutdown on a given listener
31
- # @note If true, will also obtain a lock so no-one else will be closing the same time we do
32
- def shutdown?
33
- finished? && @shutdown_mutex.try_lock
34
- end
35
-
36
- # Unlocks the shutdown lock
37
- def unlock
38
- @shutdown_mutex.unlock if @shutdown_mutex.owned?
39
- end
40
-
41
- # Marks given listener as finished
42
- # @param listener_id [String]
43
- def finish_work(listener_id)
44
- @finished << listener_id
45
- end
46
- end
47
- end
48
- end