karafka 2.5.9 → 2.6.0.beta1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/certs/expired.txt +83 -0
- data/config/locales/errors.yml +17 -7
- data/karafka.gemspec +3 -3
- data/lib/active_job/queue_adapters/karafka_adapter.rb +1 -2
- data/lib/karafka/active_job/job_extensions.rb +1 -2
- data/lib/karafka/admin/configs/resource.rb +1 -2
- data/lib/karafka/admin/consumer_groups.rb +109 -98
- data/lib/karafka/admin/isolation_levels.rb +22 -0
- data/lib/karafka/admin/topics.rb +103 -8
- data/lib/karafka/admin.rb +59 -31
- data/lib/karafka/app.rb +16 -5
- data/lib/karafka/base_consumer.rb +2 -2
- data/lib/karafka/cli/contracts/server.rb +4 -4
- data/lib/karafka/cli/info.rb +1 -1
- data/lib/karafka/cli/topics/base.rb +10 -18
- data/lib/karafka/cli/topics/repartition.rb +1 -1
- data/lib/karafka/connection/client.rb +40 -9
- data/lib/karafka/connection/consumer_groups/rebalance_manager.rb +120 -0
- data/lib/karafka/connection/listener.rb +8 -7
- data/lib/karafka/connection/listeners_batch.rb +1 -1
- data/lib/karafka/connection/mode.rb +1 -2
- data/lib/karafka/connection/raw_messages_buffer.rb +0 -5
- data/lib/karafka/declaratives/builder.rb +65 -0
- data/lib/karafka/declaratives/contracts/topic.rb +28 -0
- data/lib/karafka/declaratives/repository.rb +52 -0
- data/lib/karafka/declaratives/topic.rb +100 -0
- data/lib/karafka/declaratives.rb +9 -0
- data/lib/karafka/helpers/interval_runner.rb +2 -2
- data/lib/karafka/instrumentation/assignments_tracker.rb +65 -2
- data/lib/karafka/instrumentation/callbacks/consumer_groups/error.rb +56 -0
- data/lib/karafka/instrumentation/callbacks/consumer_groups/rebalance.rb +93 -0
- data/lib/karafka/instrumentation/callbacks/consumer_groups/statistics.rb +59 -0
- data/lib/karafka/instrumentation/logger_listener.rb +27 -9
- data/lib/karafka/instrumentation/notifications.rb +2 -0
- data/lib/karafka/instrumentation/vendors/appsignal/metrics_listener.rb +14 -17
- data/lib/karafka/instrumentation/vendors/datadog/metrics_listener.rb +8 -9
- data/lib/karafka/instrumentation/vendors/kubernetes/base_listener.rb +7 -3
- data/lib/karafka/instrumentation/vendors/kubernetes/liveness_listener.rb +13 -10
- data/lib/karafka/licenser.rb +16 -3
- data/lib/karafka/pro/active_job/consumer.rb +1 -2
- data/lib/karafka/pro/active_job/dispatcher.rb +1 -2
- data/lib/karafka/pro/admin/recovery.rb +19 -19
- data/lib/karafka/pro/base_consumer.rb +3 -3
- data/lib/karafka/pro/cli/contracts/server.rb +5 -5
- data/lib/karafka/pro/cli/parallel_segments/base.rb +7 -7
- data/lib/karafka/pro/cli/parallel_segments/collapse.rb +4 -4
- data/lib/karafka/pro/cli/parallel_segments/distribute.rb +6 -6
- data/lib/karafka/pro/iterator/tpl_builder.rb +38 -18
- data/lib/karafka/pro/loader.rb +15 -12
- data/lib/karafka/pro/processing/consumer_groups/adaptive_iterator/consumer.rb +84 -0
- data/lib/karafka/pro/processing/consumer_groups/adaptive_iterator/tracker.rb +97 -0
- data/lib/karafka/pro/processing/consumer_groups/collapser.rb +84 -0
- data/lib/karafka/pro/processing/consumer_groups/coordinator.rb +202 -0
- data/lib/karafka/pro/processing/consumer_groups/coordinators/errors_tracker.rb +124 -0
- data/lib/karafka/pro/processing/consumer_groups/coordinators/filters_applier.rb +157 -0
- data/lib/karafka/pro/processing/consumer_groups/coordinators/virtual_offset_manager.rb +212 -0
- data/lib/karafka/pro/processing/{filters/expirer.rb → consumer_groups/executor.rb} +17 -31
- data/lib/karafka/pro/processing/{jobs/periodic.rb → consumer_groups/expansions_selector.rb} +18 -21
- data/lib/karafka/pro/processing/consumer_groups/filters/base.rb +103 -0
- data/lib/karafka/pro/processing/consumer_groups/filters/delayer.rb +92 -0
- data/lib/karafka/pro/processing/consumer_groups/filters/expirer.rb +78 -0
- data/lib/karafka/pro/processing/consumer_groups/filters/inline_insights_delayer.rb +99 -0
- data/lib/karafka/pro/processing/consumer_groups/filters/throttler.rb +106 -0
- data/lib/karafka/pro/processing/consumer_groups/filters/virtual_limiter.rb +79 -0
- data/lib/karafka/pro/processing/{jobs → consumer_groups/jobs}/consume_non_blocking.rb +21 -17
- data/lib/karafka/pro/processing/{virtual_partitions/distributors/consistent.rb → consumer_groups/jobs/eofed_non_blocking.rb} +16 -14
- data/lib/karafka/pro/processing/consumer_groups/jobs/periodic.rb +64 -0
- data/lib/karafka/pro/processing/{jobs → consumer_groups/jobs}/periodic_non_blocking.rb +16 -11
- data/lib/karafka/pro/processing/{jobs → consumer_groups/jobs}/revoked_non_blocking.rb +19 -15
- data/lib/karafka/pro/processing/consumer_groups/jobs_builder.rb +95 -0
- data/lib/karafka/pro/processing/consumer_groups/offset_metadata/consumer.rb +66 -0
- data/lib/karafka/pro/processing/consumer_groups/offset_metadata/fetcher.rb +154 -0
- data/lib/karafka/pro/processing/consumer_groups/offset_metadata/listener.rb +68 -0
- data/lib/karafka/pro/processing/consumer_groups/parallel_segments/filters/base.rb +102 -0
- data/lib/karafka/pro/processing/consumer_groups/parallel_segments/filters/default.rb +115 -0
- data/lib/karafka/pro/processing/consumer_groups/parallel_segments/filters/mom.rb +96 -0
- data/lib/karafka/pro/processing/consumer_groups/partitioner.rb +98 -0
- data/lib/karafka/pro/processing/consumer_groups/periodic_job/consumer.rb +90 -0
- data/lib/karafka/pro/processing/consumer_groups/piping/consumer.rb +154 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_lrj_mom.rb +93 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_lrj_mom_vp.rb +99 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_mom.rb +92 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_mom_vp.rb +90 -0
- data/lib/karafka/pro/processing/{strategies/aj/dlq_ftr_lrj_mom.rb → consumer_groups/strategies/aj/dlq_lrj_mom.rb} +37 -39
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_lrj_mom_vp.rb +90 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_mom.rb +84 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_mom_vp.rb +89 -0
- data/lib/karafka/pro/processing/{strategies → consumer_groups/strategies}/aj/ftr_lrj_mom.rb +20 -15
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/ftr_lrj_mom_vp.rb +91 -0
- data/lib/karafka/pro/processing/{strategies → consumer_groups/strategies}/aj/ftr_mom.rb +20 -15
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/ftr_mom_vp.rb +80 -0
- data/lib/karafka/pro/processing/{strategies/mom/default.rb → consumer_groups/strategies/aj/lrj_mom.rb} +18 -22
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/lrj_mom_vp.rb +106 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/mom.rb +58 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/aj/mom_vp.rb +74 -0
- data/lib/karafka/pro/processing/{strategies/lrj/vp.rb → consumer_groups/strategies/base.rb} +9 -14
- data/lib/karafka/pro/processing/consumer_groups/strategies/default.rb +421 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/default.rb +285 -0
- data/lib/karafka/pro/processing/{strategies/dlq/lrj.rb → consumer_groups/strategies/dlq/ftr.rb} +30 -29
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_lrj.rb +95 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_lrj_mom.rb +97 -0
- data/lib/karafka/pro/processing/{executor.rb → consumer_groups/strategies/dlq/ftr_lrj_mom_vp.rb} +26 -15
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_lrj_vp.rb +63 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_mom.rb +97 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_mom_vp.rb +63 -0
- data/lib/karafka/pro/{routing/features/patterns/patterns.rb → processing/consumer_groups/strategies/dlq/ftr_vp.rb} +22 -12
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/lrj.rb +83 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/lrj_mom.rb +100 -0
- data/lib/karafka/pro/processing/{strategies → consumer_groups/strategies}/dlq/lrj_mom_vp.rb +18 -13
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/lrj_vp.rb +61 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/mom.rb +96 -0
- data/lib/karafka/pro/processing/{strategies/lrj → consumer_groups/strategies/dlq}/mom_vp.rb +19 -15
- data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/vp.rb +62 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/ftr/default.rb +146 -0
- data/lib/karafka/pro/processing/{strategies/mom/ftr.rb → consumer_groups/strategies/ftr/vp.rb} +20 -28
- data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/default.rb +119 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr.rb +94 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr_mom.rb +92 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr_mom_vp.rb +62 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr_vp.rb +61 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/mom.rb +101 -0
- data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/mom_vp.rb +60 -0
- data/lib/karafka/pro/processing/{strategies/mom → consumer_groups/strategies/lrj}/vp.rb +18 -12
- data/lib/karafka/pro/processing/{strategies/aj/mom_vp.rb → consumer_groups/strategies/mom/default.rb} +22 -23
- data/lib/karafka/pro/processing/{strategies/aj/ftr_mom_vp.rb → consumer_groups/strategies/mom/ftr.rb} +28 -28
- data/lib/karafka/pro/processing/{virtual_partitions/distributors/base.rb → consumer_groups/strategies/mom/ftr_vp.rb} +19 -14
- data/lib/karafka/pro/processing/{strategies/aj/mom.rb → consumer_groups/strategies/mom/vp.rb} +16 -12
- data/lib/karafka/pro/processing/consumer_groups/strategies/vp/default.rb +197 -0
- data/lib/karafka/pro/processing/consumer_groups/strategy_selector.rb +106 -0
- data/lib/karafka/pro/processing/consumer_groups/subscription_groups_coordinator.rb +73 -0
- data/lib/karafka/pro/processing/consumer_groups/virtual_partitions/distributors/balanced.rb +82 -0
- data/lib/karafka/pro/processing/consumer_groups/virtual_partitions/distributors/base.rb +59 -0
- data/lib/karafka/pro/processing/{strategies/dlq/ftr.rb → consumer_groups/virtual_partitions/distributors/consistent.rb} +18 -33
- data/lib/karafka/pro/processing/filters/base.rb +3 -61
- data/lib/karafka/pro/processing/partitioner.rb +2 -57
- data/lib/karafka/pro/processing/schedulers/base.rb +10 -6
- data/lib/karafka/pro/processing/schedulers/default.rb +6 -5
- data/lib/karafka/pro/recurring_tasks/executor.rb +1 -2
- data/lib/karafka/pro/routing/features/{active_job → consumer_groups/active_job}/builder.rb +20 -18
- data/lib/karafka/pro/routing/features/{inline_insights/config.rb → consumer_groups/active_job.rb} +5 -9
- data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator/config.rb +53 -0
- data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator/contracts/topic.rb +91 -0
- data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator/topic.rb +90 -0
- data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator.rb +50 -0
- data/lib/karafka/pro/routing/features/{patterns/contracts/consumer_group.rb → consumer_groups/dead_letter_queue/contracts/topic.rb} +25 -30
- data/lib/karafka/pro/routing/features/consumer_groups/dead_letter_queue/topic.rb +70 -0
- data/lib/karafka/pro/routing/features/consumer_groups/dead_letter_queue.rb +46 -0
- data/lib/karafka/pro/routing/features/{direct_assignments → consumer_groups/delaying}/config.rb +6 -4
- data/lib/karafka/pro/routing/features/{patterns/contracts/pattern.rb → consumer_groups/delaying/contracts/topic.rb} +13 -16
- data/lib/karafka/pro/routing/features/consumer_groups/delaying/topic.rb +85 -0
- data/lib/karafka/pro/routing/features/{adaptive_iterator/config.rb → consumer_groups/delaying.rb} +8 -11
- data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/config.rb +46 -0
- data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/contracts/consumer_group.rb +68 -0
- data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/contracts/topic.rb +125 -0
- data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/subscription_group.rb +97 -0
- data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/topic.rb +97 -0
- data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments.rb +44 -0
- data/lib/karafka/pro/routing/features/consumer_groups/inline_insights/config.rb +51 -0
- data/lib/karafka/pro/routing/features/consumer_groups/inline_insights/contracts/topic.rb +58 -0
- data/lib/karafka/pro/routing/features/consumer_groups/inline_insights/topic.rb +80 -0
- data/lib/karafka/pro/routing/features/consumer_groups/inline_insights.rb +45 -0
- data/lib/karafka/pro/routing/features/consumer_groups/long_running_job/config.rb +47 -0
- data/lib/karafka/pro/routing/features/{multiplexing/patches/contracts/consumer_group.rb → consumer_groups/long_running_job/contracts/topic.rb} +13 -15
- data/lib/karafka/pro/routing/features/consumer_groups/long_running_job/topic.rb +72 -0
- data/lib/karafka/pro/routing/features/{long_running_job.rb → consumer_groups/long_running_job.rb} +6 -4
- data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/config.rb +58 -0
- data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/contracts/routing.rb +83 -0
- data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/contracts/topic.rb +148 -0
- data/lib/karafka/pro/routing/features/{delaying/contracts/topic.rb → consumer_groups/multiplexing/patches/contracts/consumer_group.rb} +19 -14
- data/lib/karafka/pro/routing/features/{multiplexing/subscription_group.rb → consumer_groups/multiplexing/proxy.rb} +17 -23
- data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/subscription_group.rb +68 -0
- data/lib/karafka/pro/routing/features/{multiplexing → consumer_groups/multiplexing}/subscription_groups_builder.rb +16 -14
- data/lib/karafka/pro/routing/features/consumer_groups/multiplexing.rb +85 -0
- data/lib/karafka/pro/routing/features/consumer_groups/non_blocking_job/topic.rb +51 -0
- data/lib/karafka/pro/routing/features/{non_blocking_job.rb → consumer_groups/non_blocking_job.rb} +15 -13
- data/lib/karafka/pro/routing/features/consumer_groups/offset_metadata/config.rb +52 -0
- data/lib/karafka/pro/routing/features/consumer_groups/offset_metadata/contracts/topic.rb +59 -0
- data/lib/karafka/pro/routing/features/consumer_groups/offset_metadata/topic.rb +93 -0
- data/lib/karafka/pro/routing/features/{offset_metadata.rb → consumer_groups/offset_metadata.rb} +16 -14
- data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments/builder.rb +74 -0
- data/lib/karafka/pro/routing/features/{multiplexing → consumer_groups/parallel_segments}/config.rb +13 -15
- data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments/consumer_group.rb +110 -0
- data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments/contracts/consumer_group.rb +74 -0
- data/lib/karafka/pro/routing/features/{parallel_segments → consumer_groups/parallel_segments}/topic.rb +24 -22
- data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments.rb +51 -0
- data/lib/karafka/pro/routing/features/{patterns → consumer_groups/patterns}/builder.rb +15 -13
- data/lib/karafka/pro/routing/features/{offset_metadata/contracts/topic.rb → consumer_groups/patterns/config.rb} +28 -13
- data/lib/karafka/pro/routing/features/consumer_groups/patterns/consumer_group.rb +91 -0
- data/lib/karafka/pro/routing/features/consumer_groups/patterns/contracts/consumer_group.rb +83 -0
- data/lib/karafka/pro/routing/features/{parallel_segments.rb → consumer_groups/patterns/contracts/pattern.rb} +24 -10
- data/lib/karafka/pro/routing/features/consumer_groups/patterns/contracts/topic.rb +58 -0
- data/lib/karafka/pro/routing/features/consumer_groups/patterns/detector.rb +98 -0
- data/lib/karafka/pro/routing/features/consumer_groups/patterns/pattern.rb +114 -0
- data/lib/karafka/pro/routing/features/{recurring_tasks/contracts/topic.rb → consumer_groups/patterns/patterns.rb} +12 -13
- data/lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb +78 -0
- data/lib/karafka/pro/routing/features/consumer_groups/patterns/topics.rb +72 -0
- data/lib/karafka/pro/routing/features/consumer_groups/patterns.rb +52 -0
- data/lib/karafka/pro/routing/features/consumer_groups/periodic_job/config.rb +56 -0
- data/lib/karafka/pro/routing/features/{direct_assignments/contracts/consumer_group.rb → consumer_groups/periodic_job/contracts/topic.rb} +17 -22
- data/lib/karafka/pro/routing/features/consumer_groups/periodic_job/topic.rb +122 -0
- data/lib/karafka/pro/routing/features/consumer_groups/periodic_job.rb +46 -0
- data/lib/karafka/pro/routing/features/consumer_groups/recurring_tasks/builder.rb +150 -0
- data/lib/karafka/pro/routing/features/{swarm → consumer_groups/recurring_tasks}/config.rb +7 -8
- data/lib/karafka/pro/routing/features/{inline_insights → consumer_groups/recurring_tasks}/contracts/topic.rb +14 -13
- data/lib/karafka/pro/routing/features/{scheduled_messages → consumer_groups/recurring_tasks}/proxy.rb +6 -4
- data/lib/karafka/pro/routing/features/consumer_groups/recurring_tasks/topic.rb +72 -0
- data/lib/karafka/pro/routing/features/consumer_groups/recurring_tasks.rb +44 -0
- data/lib/karafka/pro/routing/features/consumer_groups/scheduled_messages/builder.rb +154 -0
- data/lib/karafka/pro/routing/features/consumer_groups/scheduled_messages/config.rb +47 -0
- data/lib/karafka/pro/routing/features/{long_running_job → consumer_groups/scheduled_messages}/contracts/topic.rb +14 -12
- data/lib/karafka/pro/routing/features/{delaying/config.rb → consumer_groups/scheduled_messages/proxy.rb} +6 -4
- data/lib/karafka/pro/routing/features/consumer_groups/scheduled_messages/topic.rb +72 -0
- data/lib/karafka/pro/routing/features/{recurring_tasks/proxy.rb → consumer_groups/scheduled_messages.rb} +3 -4
- data/lib/karafka/pro/routing/features/{non_blocking_job/topic.rb → consumer_groups/swarm/config.rb} +9 -8
- data/lib/karafka/pro/routing/features/consumer_groups/swarm/contracts/routing.rb +94 -0
- data/lib/karafka/pro/routing/features/consumer_groups/swarm/contracts/topic.rb +95 -0
- data/lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb +105 -0
- data/lib/karafka/pro/routing/features/consumer_groups/swarm.rb +58 -0
- data/lib/karafka/pro/routing/features/consumer_groups/virtual_partitions/config.rb +69 -0
- data/lib/karafka/pro/routing/features/{parallel_segments/contracts/consumer_group.rb → consumer_groups/virtual_partitions/contracts/topic.rb} +21 -18
- data/lib/karafka/pro/routing/features/consumer_groups/virtual_partitions/topic.rb +101 -0
- data/lib/karafka/pro/routing/features/consumer_groups/virtual_partitions.rb +46 -0
- data/lib/karafka/pro/routing/features/{scheduled_messages.rb → consumer_groups.rb} +3 -2
- data/lib/karafka/pro/routing/features/expiring/topic.rb +4 -4
- data/lib/karafka/pro/routing/features/filtering/topic.rb +3 -3
- data/lib/karafka/pro/routing/features/pausing/topic.rb +3 -3
- data/lib/karafka/pro/routing/features/throttling/topic.rb +4 -4
- data/lib/karafka/pro/setup/defaults_injector.rb +70 -0
- data/lib/karafka/pro/swarm/liveness_listener.rb +22 -10
- data/lib/karafka/processing/consumer_groups/coordinator.rb +221 -0
- data/lib/karafka/processing/consumer_groups/coordinators_buffer.rb +69 -0
- data/lib/karafka/processing/consumer_groups/executor.rb +220 -0
- data/lib/karafka/processing/consumer_groups/executors_buffer.rb +94 -0
- data/lib/karafka/processing/consumer_groups/expansions_selector.rb +26 -0
- data/lib/karafka/processing/consumer_groups/inline_insights/consumer.rb +47 -0
- data/lib/karafka/processing/consumer_groups/inline_insights/listener.rb +23 -0
- data/lib/karafka/processing/consumer_groups/inline_insights/tracker.rb +132 -0
- data/lib/karafka/processing/consumer_groups/jobs/consume.rb +52 -0
- data/lib/karafka/processing/consumer_groups/jobs/eofed.rb +34 -0
- data/lib/karafka/processing/consumer_groups/jobs/idle.rb +33 -0
- data/lib/karafka/processing/consumer_groups/jobs/revoked.rb +34 -0
- data/lib/karafka/processing/consumer_groups/jobs/shutdown.rb +32 -0
- data/lib/karafka/processing/consumer_groups/jobs_builder.rb +36 -0
- data/lib/karafka/processing/consumer_groups/partitioner.rb +28 -0
- data/lib/karafka/processing/consumer_groups/strategies/aj_dlq_mom.rb +48 -0
- data/lib/karafka/processing/consumer_groups/strategies/aj_mom.rb +25 -0
- data/lib/karafka/processing/consumer_groups/strategies/base.rb +65 -0
- data/lib/karafka/processing/consumer_groups/strategies/default.rb +218 -0
- data/lib/karafka/processing/consumer_groups/strategies/dlq.rb +157 -0
- data/lib/karafka/processing/consumer_groups/strategies/dlq_mom.rb +72 -0
- data/lib/karafka/processing/consumer_groups/strategies/mom.rb +33 -0
- data/lib/karafka/processing/consumer_groups/strategy_selector.rb +53 -0
- data/lib/karafka/processing/coordinator.rb +4 -211
- data/lib/karafka/processing/coordinators_buffer.rb +4 -59
- data/lib/karafka/processing/jobs_queue.rb +12 -4
- data/lib/karafka/processing/partitioner.rb +4 -18
- data/lib/karafka/processing/schedulers/default.rb +2 -1
- data/lib/karafka/processing/strategy_selector.rb +4 -42
- data/lib/karafka/processing/worker.rb +8 -4
- data/lib/karafka/processing/workers_pool.rb +158 -0
- data/lib/karafka/routing/builder.rb +12 -12
- data/lib/karafka/routing/contracts/routing.rb +3 -4
- data/lib/karafka/routing/features/base/expander.rb +5 -5
- data/lib/karafka/routing/features/consumer_groups/active_job/builder.rb +35 -0
- data/lib/karafka/routing/features/consumer_groups/active_job/config.rb +17 -0
- data/lib/karafka/routing/features/consumer_groups/active_job/contracts/topic.rb +44 -0
- data/lib/karafka/routing/features/consumer_groups/active_job/proxy.rb +16 -0
- data/lib/karafka/routing/features/consumer_groups/active_job/topic.rb +50 -0
- data/lib/karafka/routing/features/consumer_groups/active_job.rb +15 -0
- data/lib/karafka/routing/features/consumer_groups/dead_letter_queue/config.rb +39 -0
- data/lib/karafka/routing/features/consumer_groups/dead_letter_queue/contracts/topic.rb +58 -0
- data/lib/karafka/routing/features/consumer_groups/dead_letter_queue/topic.rb +76 -0
- data/lib/karafka/routing/features/consumer_groups/dead_letter_queue.rb +18 -0
- data/lib/karafka/routing/features/consumer_groups/eofed/config.rb +17 -0
- data/lib/karafka/routing/features/consumer_groups/eofed/contracts/topic.rb +39 -0
- data/lib/karafka/routing/features/consumer_groups/eofed/topic.rb +42 -0
- data/lib/karafka/routing/features/consumer_groups/eofed.rb +16 -0
- data/lib/karafka/routing/features/consumer_groups/inline_insights/config.rb +17 -0
- data/lib/karafka/routing/features/consumer_groups/inline_insights/contracts/topic.rb +27 -0
- data/lib/karafka/routing/features/consumer_groups/inline_insights/topic.rb +42 -0
- data/lib/karafka/routing/features/consumer_groups/inline_insights.rb +42 -0
- data/lib/karafka/routing/features/consumer_groups/manual_offset_management/config.rb +17 -0
- data/lib/karafka/routing/features/consumer_groups/manual_offset_management/contracts/topic.rb +27 -0
- data/lib/karafka/routing/features/consumer_groups/manual_offset_management/topic.rb +46 -0
- data/lib/karafka/routing/features/consumer_groups/manual_offset_management.rb +20 -0
- data/lib/karafka/routing/features/consumer_groups.rb +12 -0
- data/lib/karafka/routing/features/declaratives/contracts/topic.rb +4 -19
- data/lib/karafka/routing/features/declaratives/topic.rb +30 -14
- data/lib/karafka/routing/features/deserializers/topic.rb +3 -3
- data/lib/karafka/routing/router.rb +2 -2
- data/lib/karafka/routing/subscription_group.rb +18 -9
- data/lib/karafka/routing/topic.rb +25 -11
- data/lib/karafka/runner.rb +17 -17
- data/lib/karafka/server.rb +28 -6
- data/lib/karafka/setup/attributes_map.rb +2 -0
- data/lib/karafka/setup/config.rb +64 -15
- data/lib/karafka/setup/config_proxy.rb +1 -2
- data/lib/karafka/setup/contracts/config.rb +28 -8
- data/lib/karafka/setup/defaults_injector.rb +10 -0
- data/lib/karafka/status.rb +1 -2
- data/lib/karafka/swarm/liveness_listener.rb +7 -0
- data/lib/karafka/swarm/manager.rb +7 -7
- data/lib/karafka/swarm/node.rb +8 -0
- data/lib/karafka/swarm/supervisor.rb +9 -1
- data/lib/karafka/templates/karafka.rb.erb +11 -5
- data/lib/karafka/version.rb +1 -1
- metadata +237 -224
- data/lib/karafka/connection/rebalance_manager.rb +0 -116
- data/lib/karafka/instrumentation/callbacks/error.rb +0 -52
- data/lib/karafka/instrumentation/callbacks/rebalance.rb +0 -84
- data/lib/karafka/instrumentation/callbacks/statistics.rb +0 -55
- data/lib/karafka/pro/processing/adaptive_iterator/consumer.rb +0 -79
- data/lib/karafka/pro/processing/adaptive_iterator/tracker.rb +0 -92
- data/lib/karafka/pro/processing/collapser.rb +0 -79
- data/lib/karafka/pro/processing/coordinator.rb +0 -197
- data/lib/karafka/pro/processing/coordinators/errors_tracker.rb +0 -119
- data/lib/karafka/pro/processing/coordinators/filters_applier.rb +0 -152
- data/lib/karafka/pro/processing/coordinators/virtual_offset_manager.rb +0 -207
- data/lib/karafka/pro/processing/expansions_selector.rb +0 -52
- data/lib/karafka/pro/processing/filters/delayer.rb +0 -87
- data/lib/karafka/pro/processing/filters/inline_insights_delayer.rb +0 -95
- data/lib/karafka/pro/processing/filters/throttler.rb +0 -101
- data/lib/karafka/pro/processing/filters/virtual_limiter.rb +0 -74
- data/lib/karafka/pro/processing/jobs/eofed_non_blocking.rb +0 -51
- data/lib/karafka/pro/processing/jobs_builder.rb +0 -90
- data/lib/karafka/pro/processing/offset_metadata/consumer.rb +0 -61
- data/lib/karafka/pro/processing/offset_metadata/fetcher.rb +0 -149
- data/lib/karafka/pro/processing/offset_metadata/listener.rb +0 -63
- data/lib/karafka/pro/processing/parallel_segments/filters/base.rb +0 -98
- data/lib/karafka/pro/processing/parallel_segments/filters/default.rb +0 -110
- data/lib/karafka/pro/processing/parallel_segments/filters/mom.rb +0 -91
- data/lib/karafka/pro/processing/periodic_job/consumer.rb +0 -85
- data/lib/karafka/pro/processing/piping/consumer.rb +0 -149
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom_vp.rb +0 -94
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom.rb +0 -87
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom_vp.rb +0 -85
- data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom.rb +0 -81
- data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom_vp.rb +0 -85
- data/lib/karafka/pro/processing/strategies/aj/dlq_mom.rb +0 -79
- data/lib/karafka/pro/processing/strategies/aj/dlq_mom_vp.rb +0 -84
- data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom_vp.rb +0 -86
- data/lib/karafka/pro/processing/strategies/aj/lrj_mom.rb +0 -54
- data/lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb +0 -101
- data/lib/karafka/pro/processing/strategies/base.rb +0 -43
- data/lib/karafka/pro/processing/strategies/default.rb +0 -416
- data/lib/karafka/pro/processing/strategies/dlq/default.rb +0 -280
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj.rb +0 -90
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom.rb +0 -92
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom_vp.rb +0 -60
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_vp.rb +0 -58
- data/lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb +0 -92
- data/lib/karafka/pro/processing/strategies/dlq/ftr_mom_vp.rb +0 -58
- data/lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb +0 -57
- data/lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb +0 -95
- data/lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb +0 -56
- data/lib/karafka/pro/processing/strategies/dlq/mom.rb +0 -91
- data/lib/karafka/pro/processing/strategies/dlq/mom_vp.rb +0 -54
- data/lib/karafka/pro/processing/strategies/dlq/vp.rb +0 -57
- data/lib/karafka/pro/processing/strategies/ftr/default.rb +0 -141
- data/lib/karafka/pro/processing/strategies/ftr/vp.rb +0 -57
- data/lib/karafka/pro/processing/strategies/lrj/default.rb +0 -114
- data/lib/karafka/pro/processing/strategies/lrj/ftr.rb +0 -89
- data/lib/karafka/pro/processing/strategies/lrj/ftr_mom.rb +0 -87
- data/lib/karafka/pro/processing/strategies/lrj/ftr_mom_vp.rb +0 -57
- data/lib/karafka/pro/processing/strategies/lrj/ftr_vp.rb +0 -56
- data/lib/karafka/pro/processing/strategies/lrj/mom.rb +0 -96
- data/lib/karafka/pro/processing/strategies/mom/ftr_vp.rb +0 -54
- data/lib/karafka/pro/processing/strategies/vp/default.rb +0 -192
- data/lib/karafka/pro/processing/strategies.rb +0 -39
- data/lib/karafka/pro/processing/strategy_selector.rb +0 -102
- data/lib/karafka/pro/processing/subscription_groups_coordinator.rb +0 -68
- data/lib/karafka/pro/processing/virtual_partitions/distributors/balanced.rb +0 -77
- data/lib/karafka/pro/routing/features/active_job.rb +0 -43
- data/lib/karafka/pro/routing/features/adaptive_iterator/contracts/topic.rb +0 -89
- data/lib/karafka/pro/routing/features/adaptive_iterator/topic.rb +0 -88
- data/lib/karafka/pro/routing/features/adaptive_iterator.rb +0 -48
- data/lib/karafka/pro/routing/features/dead_letter_queue/contracts/topic.rb +0 -74
- data/lib/karafka/pro/routing/features/dead_letter_queue/topic.rb +0 -68
- data/lib/karafka/pro/routing/features/dead_letter_queue.rb +0 -44
- data/lib/karafka/pro/routing/features/delaying/topic.rb +0 -83
- data/lib/karafka/pro/routing/features/delaying.rb +0 -46
- data/lib/karafka/pro/routing/features/direct_assignments/contracts/topic.rb +0 -123
- data/lib/karafka/pro/routing/features/direct_assignments/subscription_group.rb +0 -95
- data/lib/karafka/pro/routing/features/direct_assignments/topic.rb +0 -95
- data/lib/karafka/pro/routing/features/direct_assignments.rb +0 -42
- data/lib/karafka/pro/routing/features/inline_insights/topic.rb +0 -78
- data/lib/karafka/pro/routing/features/inline_insights.rb +0 -43
- data/lib/karafka/pro/routing/features/long_running_job/config.rb +0 -45
- data/lib/karafka/pro/routing/features/long_running_job/topic.rb +0 -70
- data/lib/karafka/pro/routing/features/multiplexing/contracts/routing.rb +0 -81
- data/lib/karafka/pro/routing/features/multiplexing/contracts/topic.rb +0 -146
- data/lib/karafka/pro/routing/features/multiplexing/proxy.rb +0 -58
- data/lib/karafka/pro/routing/features/multiplexing.rb +0 -83
- data/lib/karafka/pro/routing/features/offset_metadata/config.rb +0 -50
- data/lib/karafka/pro/routing/features/offset_metadata/topic.rb +0 -91
- data/lib/karafka/pro/routing/features/parallel_segments/builder.rb +0 -72
- data/lib/karafka/pro/routing/features/parallel_segments/config.rb +0 -52
- data/lib/karafka/pro/routing/features/parallel_segments/consumer_group.rb +0 -108
- data/lib/karafka/pro/routing/features/patterns/config.rb +0 -71
- data/lib/karafka/pro/routing/features/patterns/consumer_group.rb +0 -89
- data/lib/karafka/pro/routing/features/patterns/contracts/topic.rb +0 -56
- data/lib/karafka/pro/routing/features/patterns/detector.rb +0 -96
- data/lib/karafka/pro/routing/features/patterns/pattern.rb +0 -112
- data/lib/karafka/pro/routing/features/patterns/topic.rb +0 -76
- data/lib/karafka/pro/routing/features/patterns/topics.rb +0 -70
- data/lib/karafka/pro/routing/features/patterns.rb +0 -50
- data/lib/karafka/pro/routing/features/periodic_job/config.rb +0 -54
- data/lib/karafka/pro/routing/features/periodic_job/contracts/topic.rb +0 -59
- data/lib/karafka/pro/routing/features/periodic_job/topic.rb +0 -120
- data/lib/karafka/pro/routing/features/periodic_job.rb +0 -44
- data/lib/karafka/pro/routing/features/recurring_tasks/builder.rb +0 -148
- data/lib/karafka/pro/routing/features/recurring_tasks/config.rb +0 -45
- data/lib/karafka/pro/routing/features/recurring_tasks/topic.rb +0 -70
- data/lib/karafka/pro/routing/features/recurring_tasks.rb +0 -42
- data/lib/karafka/pro/routing/features/scheduled_messages/builder.rb +0 -152
- data/lib/karafka/pro/routing/features/scheduled_messages/config.rb +0 -45
- data/lib/karafka/pro/routing/features/scheduled_messages/contracts/topic.rb +0 -55
- data/lib/karafka/pro/routing/features/scheduled_messages/topic.rb +0 -70
- data/lib/karafka/pro/routing/features/swarm/contracts/routing.rb +0 -92
- data/lib/karafka/pro/routing/features/swarm/contracts/topic.rb +0 -93
- data/lib/karafka/pro/routing/features/swarm/topic.rb +0 -103
- data/lib/karafka/pro/routing/features/swarm.rb +0 -56
- data/lib/karafka/pro/routing/features/virtual_partitions/config.rb +0 -67
- data/lib/karafka/pro/routing/features/virtual_partitions/contracts/topic.rb +0 -73
- data/lib/karafka/pro/routing/features/virtual_partitions/topic.rb +0 -99
- data/lib/karafka/pro/routing/features/virtual_partitions.rb +0 -44
- data/lib/karafka/processing/executor.rb +0 -216
- data/lib/karafka/processing/executors_buffer.rb +0 -90
- data/lib/karafka/processing/expansions_selector.rb +0 -22
- data/lib/karafka/processing/inline_insights/consumer.rb +0 -43
- data/lib/karafka/processing/inline_insights/listener.rb +0 -19
- data/lib/karafka/processing/inline_insights/tracker.rb +0 -129
- data/lib/karafka/processing/jobs/consume.rb +0 -47
- data/lib/karafka/processing/jobs/eofed.rb +0 -29
- data/lib/karafka/processing/jobs/idle.rb +0 -31
- data/lib/karafka/processing/jobs/revoked.rb +0 -29
- data/lib/karafka/processing/jobs/shutdown.rb +0 -30
- data/lib/karafka/processing/jobs_builder.rb +0 -34
- data/lib/karafka/processing/strategies/aj_dlq_mom.rb +0 -44
- data/lib/karafka/processing/strategies/aj_mom.rb +0 -21
- data/lib/karafka/processing/strategies/base.rb +0 -61
- data/lib/karafka/processing/strategies/default.rb +0 -214
- data/lib/karafka/processing/strategies/dlq.rb +0 -153
- data/lib/karafka/processing/strategies/dlq_mom.rb +0 -68
- data/lib/karafka/processing/strategies/mom.rb +0 -29
- data/lib/karafka/processing/workers_batch.rb +0 -29
- data/lib/karafka/routing/features/active_job/builder.rb +0 -33
- data/lib/karafka/routing/features/active_job/config.rb +0 -15
- data/lib/karafka/routing/features/active_job/contracts/topic.rb +0 -42
- data/lib/karafka/routing/features/active_job/proxy.rb +0 -14
- data/lib/karafka/routing/features/active_job/topic.rb +0 -48
- data/lib/karafka/routing/features/active_job.rb +0 -13
- data/lib/karafka/routing/features/dead_letter_queue/config.rb +0 -37
- data/lib/karafka/routing/features/dead_letter_queue/contracts/topic.rb +0 -56
- data/lib/karafka/routing/features/dead_letter_queue/topic.rb +0 -74
- data/lib/karafka/routing/features/dead_letter_queue.rb +0 -16
- data/lib/karafka/routing/features/declaratives/config.rb +0 -18
- data/lib/karafka/routing/features/eofed/config.rb +0 -15
- data/lib/karafka/routing/features/eofed/contracts/topic.rb +0 -37
- data/lib/karafka/routing/features/eofed/topic.rb +0 -40
- data/lib/karafka/routing/features/eofed.rb +0 -14
- data/lib/karafka/routing/features/inline_insights/config.rb +0 -15
- data/lib/karafka/routing/features/inline_insights/contracts/topic.rb +0 -25
- data/lib/karafka/routing/features/inline_insights/topic.rb +0 -40
- data/lib/karafka/routing/features/inline_insights.rb +0 -40
- data/lib/karafka/routing/features/manual_offset_management/config.rb +0 -15
- data/lib/karafka/routing/features/manual_offset_management/contracts/topic.rb +0 -25
- data/lib/karafka/routing/features/manual_offset_management/topic.rb +0 -44
- data/lib/karafka/routing/features/manual_offset_management.rb +0 -18
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Karafka Pro - Source Available Commercial Software
|
|
4
|
+
# Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
|
|
5
|
+
#
|
|
6
|
+
# This software is NOT open source. It is source-available commercial software
|
|
7
|
+
# requiring a paid license for use. It is NOT covered by LGPL.
|
|
8
|
+
#
|
|
9
|
+
# The author retains all right, title, and interest in this software,
|
|
10
|
+
# including all copyrights, patents, and other intellectual property rights.
|
|
11
|
+
# No patent rights are granted under this license.
|
|
12
|
+
#
|
|
13
|
+
# PROHIBITED:
|
|
14
|
+
# - Use without a valid commercial license
|
|
15
|
+
# - Redistribution, modification, or derivative works without authorization
|
|
16
|
+
# - Reverse engineering, decompilation, or disassembly of this software
|
|
17
|
+
# - Use as training data for AI/ML models or inclusion in datasets
|
|
18
|
+
# - Scraping, crawling, or automated collection for any purpose
|
|
19
|
+
#
|
|
20
|
+
# PERMITTED:
|
|
21
|
+
# - Reading, referencing, and linking for personal or commercial use
|
|
22
|
+
# - Runtime retrieval by AI assistants, coding agents, and RAG systems
|
|
23
|
+
# for the purpose of providing contextual help to Karafka users
|
|
24
|
+
#
|
|
25
|
+
# Receipt, viewing, or possession of this software does not convey or
|
|
26
|
+
# imply any license or right beyond those expressly stated above.
|
|
27
|
+
#
|
|
28
|
+
# License: https://karafka.io/docs/Pro-License-Comm/
|
|
29
|
+
# Contact: contact@karafka.io
|
|
30
|
+
|
|
31
|
+
module Karafka
|
|
32
|
+
module Pro
|
|
33
|
+
module Routing
|
|
34
|
+
module Features
|
|
35
|
+
module ConsumerGroups
|
|
36
|
+
class VirtualPartitions < Base
|
|
37
|
+
# Topic extensions to be able to manage virtual partitions feature
|
|
38
|
+
module Topic
|
|
39
|
+
# This method sets up the extra instance variable to nil before calling
|
|
40
|
+
# the parent class initializer. The explicit initialization
|
|
41
|
+
# to nil is included as an optimization for Ruby's object shapes system,
|
|
42
|
+
# which improves memory layout and access performance.
|
|
43
|
+
def initialize(...)
|
|
44
|
+
@virtual_partitions = nil
|
|
45
|
+
super
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# @param max_partitions [Integer] max number of virtual partitions that can come out of
|
|
49
|
+
# the single distribution flow. When set to more than the Karafka threading, will
|
|
50
|
+
# create more work than workers. When less, can ensure we have spare resources to
|
|
51
|
+
# process other things in parallel.
|
|
52
|
+
# @param partitioner [nil, #call] nil or callable partitioner
|
|
53
|
+
# @param offset_metadata_strategy [Symbol] how we should match the metadata for the
|
|
54
|
+
# offset. `:exact` will match the offset matching metadata and `:current` will select
|
|
55
|
+
# the most recently reported metadata
|
|
56
|
+
# @param reducer [nil, #call] reducer for VPs key. It allows for using a custom
|
|
57
|
+
# reducer to achieve enhanced parallelization when the default reducer is not enough.
|
|
58
|
+
# @param distribution [Symbol] the strategy to use for virtual partitioning. Can be
|
|
59
|
+
# either `:consistent` or `:balanced`. The `:balanced` strategy ensures balanced
|
|
60
|
+
# distribution of work across available workers while maintaining message order
|
|
61
|
+
# within groups.
|
|
62
|
+
# @return [VirtualPartitions] method that allows to set the virtual partitions details
|
|
63
|
+
# during the routing configuration and then allows to retrieve it
|
|
64
|
+
def virtual_partitions(
|
|
65
|
+
max_partitions: Karafka::App.config.concurrency,
|
|
66
|
+
partitioner: nil,
|
|
67
|
+
offset_metadata_strategy: :current,
|
|
68
|
+
reducer: nil,
|
|
69
|
+
distribution: :consistent
|
|
70
|
+
)
|
|
71
|
+
@virtual_partitions ||= Config.new(
|
|
72
|
+
active: !partitioner.nil?,
|
|
73
|
+
max_partitions: max_partitions,
|
|
74
|
+
partitioner: partitioner,
|
|
75
|
+
offset_metadata_strategy: offset_metadata_strategy,
|
|
76
|
+
# If no reducer provided, we use this one. It just runs a modulo on the sum of
|
|
77
|
+
# a stringified version, providing fairly good distribution.
|
|
78
|
+
reducer: reducer || ->(virtual_key) { virtual_key.to_s.sum % max_partitions },
|
|
79
|
+
distribution: distribution
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @return [Boolean] are virtual partitions enabled for given topic
|
|
84
|
+
def virtual_partitions?
|
|
85
|
+
virtual_partitions.active?
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @return [Hash] topic with all its native configuration options plus manual offset
|
|
89
|
+
# management namespace settings
|
|
90
|
+
def to_h
|
|
91
|
+
super.merge(
|
|
92
|
+
virtual_partitions: virtual_partitions.to_h
|
|
93
|
+
).freeze
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Karafka Pro - Source Available Commercial Software
|
|
4
|
+
# Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
|
|
5
|
+
#
|
|
6
|
+
# This software is NOT open source. It is source-available commercial software
|
|
7
|
+
# requiring a paid license for use. It is NOT covered by LGPL.
|
|
8
|
+
#
|
|
9
|
+
# The author retains all right, title, and interest in this software,
|
|
10
|
+
# including all copyrights, patents, and other intellectual property rights.
|
|
11
|
+
# No patent rights are granted under this license.
|
|
12
|
+
#
|
|
13
|
+
# PROHIBITED:
|
|
14
|
+
# - Use without a valid commercial license
|
|
15
|
+
# - Redistribution, modification, or derivative works without authorization
|
|
16
|
+
# - Reverse engineering, decompilation, or disassembly of this software
|
|
17
|
+
# - Use as training data for AI/ML models or inclusion in datasets
|
|
18
|
+
# - Scraping, crawling, or automated collection for any purpose
|
|
19
|
+
#
|
|
20
|
+
# PERMITTED:
|
|
21
|
+
# - Reading, referencing, and linking for personal or commercial use
|
|
22
|
+
# - Runtime retrieval by AI assistants, coding agents, and RAG systems
|
|
23
|
+
# for the purpose of providing contextual help to Karafka users
|
|
24
|
+
#
|
|
25
|
+
# Receipt, viewing, or possession of this software does not convey or
|
|
26
|
+
# imply any license or right beyond those expressly stated above.
|
|
27
|
+
#
|
|
28
|
+
# License: https://karafka.io/docs/Pro-License-Comm/
|
|
29
|
+
# Contact: contact@karafka.io
|
|
30
|
+
|
|
31
|
+
module Karafka
|
|
32
|
+
module Pro
|
|
33
|
+
module Routing
|
|
34
|
+
module Features
|
|
35
|
+
module ConsumerGroups
|
|
36
|
+
# Virtual Partitions feature config and DSL namespace.
|
|
37
|
+
#
|
|
38
|
+
# Virtual Partitions allow you to parallelize the processing of data from a single
|
|
39
|
+
# partition. This can drastically increase throughput when IO operations are involved.
|
|
40
|
+
class VirtualPartitions < Base
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -32,8 +32,9 @@ module Karafka
|
|
|
32
32
|
module Pro
|
|
33
33
|
module Routing
|
|
34
34
|
module Features
|
|
35
|
-
#
|
|
36
|
-
|
|
35
|
+
# Consumer-group-specific Pro routing features. A parallel `ShareGroups` namespace will
|
|
36
|
+
# hold share-group-specific feature implementations once KIP-932 lands.
|
|
37
|
+
module ConsumerGroups
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
end
|
|
@@ -35,13 +35,13 @@ module Karafka
|
|
|
35
35
|
class Expiring < Base
|
|
36
36
|
# Topic expiring API extensions
|
|
37
37
|
module Topic
|
|
38
|
-
# This method
|
|
39
|
-
#
|
|
38
|
+
# This method sets up the extra instance variable to nil before calling
|
|
39
|
+
# the parent class initializer. The explicit initialization
|
|
40
40
|
# to nil is included as an optimization for Ruby's object shapes system,
|
|
41
41
|
# which improves memory layout and access performance.
|
|
42
42
|
def initialize(...)
|
|
43
|
-
super
|
|
44
43
|
@expiring = nil
|
|
44
|
+
super
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# @param ttl [Integer, nil] maximum time in ms a message is considered alive
|
|
@@ -51,7 +51,7 @@ module Karafka
|
|
|
51
51
|
config = Config.new(active: !ttl.nil?, ttl: ttl)
|
|
52
52
|
|
|
53
53
|
if config.active?
|
|
54
|
-
factory = ->(*) { Pro::Processing::Filters::Expirer.new(ttl) }
|
|
54
|
+
factory = ->(*) { Pro::Processing::ConsumerGroups::Filters::Expirer.new(ttl) }
|
|
55
55
|
filter(factory)
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -35,13 +35,13 @@ module Karafka
|
|
|
35
35
|
class Filtering < Base
|
|
36
36
|
# Filtering feature topic extensions
|
|
37
37
|
module Topic
|
|
38
|
-
# This method
|
|
39
|
-
#
|
|
38
|
+
# This method sets up the extra instance variable to nil before calling
|
|
39
|
+
# the parent class initializer. The explicit initialization
|
|
40
40
|
# to nil is included as an optimization for Ruby's object shapes system,
|
|
41
41
|
# which improves memory layout and access performance.
|
|
42
42
|
def initialize(...)
|
|
43
|
-
super
|
|
44
43
|
@filtering = nil
|
|
44
|
+
super
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# @param factory [#call, nil] Callable that can produce new filters instances per
|
|
@@ -35,13 +35,13 @@ module Karafka
|
|
|
35
35
|
class Pausing < Base
|
|
36
36
|
# Expansion allowing for a per topic pause strategy definitions
|
|
37
37
|
module Topic
|
|
38
|
-
# This method
|
|
39
|
-
#
|
|
38
|
+
# This method sets up the extra instance variable to nil before calling
|
|
39
|
+
# the parent class initializer. The explicit initialization
|
|
40
40
|
# to nil is included as an optimization for Ruby's object shapes system,
|
|
41
41
|
# which improves memory layout and access performance.
|
|
42
42
|
def initialize(...)
|
|
43
|
-
super
|
|
44
43
|
@pausing = nil
|
|
44
|
+
super
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Allows for per-topic pausing strategy setting
|
|
@@ -35,13 +35,13 @@ module Karafka
|
|
|
35
35
|
class Throttling < Base
|
|
36
36
|
# Topic throttling API extensions
|
|
37
37
|
module Topic
|
|
38
|
-
# This method
|
|
39
|
-
#
|
|
38
|
+
# This method sets up the extra instance variable to nil before calling
|
|
39
|
+
# the parent class initializer. The explicit initialization
|
|
40
40
|
# to nil is included as an optimization for Ruby's object shapes system,
|
|
41
41
|
# which improves memory layout and access performance.
|
|
42
42
|
def initialize(...)
|
|
43
|
-
super
|
|
44
43
|
@throttling = nil
|
|
44
|
+
super
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# @param limit [Integer] max messages to process in an time interval
|
|
@@ -61,7 +61,7 @@ module Karafka
|
|
|
61
61
|
# If someone defined throttling setup, we need to create appropriate filter for it
|
|
62
62
|
# and inject it via filtering feature
|
|
63
63
|
if config.active?
|
|
64
|
-
factory = ->(*) { Pro::Processing::Filters::Throttler.new(limit, interval) }
|
|
64
|
+
factory = ->(*) { Pro::Processing::ConsumerGroups::Filters::Throttler.new(limit, interval) }
|
|
65
65
|
filter(factory)
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Karafka Pro - Source Available Commercial Software
|
|
4
|
+
# Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
|
|
5
|
+
#
|
|
6
|
+
# This software is NOT open source. It is source-available commercial software
|
|
7
|
+
# requiring a paid license for use. It is NOT covered by LGPL.
|
|
8
|
+
#
|
|
9
|
+
# The author retains all right, title, and interest in this software,
|
|
10
|
+
# including all copyrights, patents, and other intellectual property rights.
|
|
11
|
+
# No patent rights are granted under this license.
|
|
12
|
+
#
|
|
13
|
+
# PROHIBITED:
|
|
14
|
+
# - Use without a valid commercial license
|
|
15
|
+
# - Redistribution, modification, or derivative works without authorization
|
|
16
|
+
# - Reverse engineering, decompilation, or disassembly of this software
|
|
17
|
+
# - Use as training data for AI/ML models or inclusion in datasets
|
|
18
|
+
# - Scraping, crawling, or automated collection for any purpose
|
|
19
|
+
#
|
|
20
|
+
# PERMITTED:
|
|
21
|
+
# - Reading, referencing, and linking for personal or commercial use
|
|
22
|
+
# - Runtime retrieval by AI assistants, coding agents, and RAG systems
|
|
23
|
+
# for the purpose of providing contextual help to Karafka users
|
|
24
|
+
#
|
|
25
|
+
# Receipt, viewing, or possession of this software does not convey or
|
|
26
|
+
# imply any license or right beyond those expressly stated above.
|
|
27
|
+
#
|
|
28
|
+
# License: https://karafka.io/docs/Pro-License-Comm/
|
|
29
|
+
# Contact: contact@karafka.io
|
|
30
|
+
|
|
31
|
+
module Karafka
|
|
32
|
+
module Pro
|
|
33
|
+
# Namespace for Pro setup components
|
|
34
|
+
module Setup
|
|
35
|
+
# Pro defaults injector that extends the OSS defaults with Pro-specific settings
|
|
36
|
+
module DefaultsInjector
|
|
37
|
+
# Pro-specific consumer kafka defaults
|
|
38
|
+
# These defaults are carefully tuned to work with Pro's internal statistics aggregation,
|
|
39
|
+
# the Web UI dashboard, and the performance tracker. They depend on Pro's extended
|
|
40
|
+
# instrumentation pipeline and should not be applied outside of Pro as they may cause
|
|
41
|
+
# incomplete or inconsistent metrics collection and other unexpected behaviours.
|
|
42
|
+
CONSUMER_KAFKA_DEFAULTS = {
|
|
43
|
+
"statistics.unassigned.include": false
|
|
44
|
+
}.freeze
|
|
45
|
+
|
|
46
|
+
private_constant :CONSUMER_KAFKA_DEFAULTS
|
|
47
|
+
|
|
48
|
+
# Pro actively manages these keys via its own DefaultsInjector so users are allowed
|
|
49
|
+
# to set them if needed.
|
|
50
|
+
#
|
|
51
|
+
# @return [Set<Symbol>] empty set since Pro handles these keys
|
|
52
|
+
def managed_keys
|
|
53
|
+
@managed_keys ||= Set.new
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Enriches consumer kafka config with Pro-specific defaults
|
|
57
|
+
# @param kafka_config [Hash] kafka scoped config
|
|
58
|
+
def consumer(kafka_config)
|
|
59
|
+
super
|
|
60
|
+
|
|
61
|
+
CONSUMER_KAFKA_DEFAULTS.each do |key, value|
|
|
62
|
+
next if kafka_config.key?(key)
|
|
63
|
+
|
|
64
|
+
kafka_config[key] = value
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -73,6 +73,13 @@ module Karafka
|
|
|
73
73
|
super()
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
+
# Report status before the first fetch loop iteration so the supervisor gets an initial
|
|
77
|
+
# healthy report even if the first consumption takes longer than the report timeout.
|
|
78
|
+
# @param _event [Karafka::Core::Monitoring::Event]
|
|
79
|
+
def on_connection_listener_before_fetch_loop(_event)
|
|
80
|
+
report_status
|
|
81
|
+
end
|
|
82
|
+
|
|
76
83
|
# Tick on each fetch and report liveness so it works even when statistics are disabled
|
|
77
84
|
#
|
|
78
85
|
# @param _event [Karafka::Core::Monitoring::Event]
|
|
@@ -143,42 +150,47 @@ module Karafka
|
|
|
143
150
|
periodically do
|
|
144
151
|
return unless node
|
|
145
152
|
|
|
153
|
+
Kernel.exit!(orphaned_exit_code) if node.orphaned?
|
|
154
|
+
|
|
146
155
|
current_status = status
|
|
147
156
|
|
|
148
157
|
current_status.positive? ? node.unhealthy(current_status) : node.healthy
|
|
149
158
|
end
|
|
150
159
|
end
|
|
151
160
|
|
|
152
|
-
# @return [Integer] object id of the current
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
# @return [Integer] object id of the current fiber
|
|
162
|
+
# @note We use fiber object id instead of thread object id to ensure fiber-safety.
|
|
163
|
+
# Multiple fibers can run on the same thread, and using thread id would cause them
|
|
164
|
+
# to overwrite each other's timestamps.
|
|
165
|
+
def fiber_id
|
|
166
|
+
Fiber.current.object_id
|
|
155
167
|
end
|
|
156
168
|
|
|
157
|
-
# Update the polling tick time for current
|
|
169
|
+
# Update the polling tick time for current fiber
|
|
158
170
|
def mark_polling_tick
|
|
159
171
|
synchronize do
|
|
160
|
-
@pollings[
|
|
172
|
+
@pollings[fiber_id] = monotonic_now
|
|
161
173
|
end
|
|
162
174
|
end
|
|
163
175
|
|
|
164
|
-
# Clear current
|
|
176
|
+
# Clear current fiber polling time tracker
|
|
165
177
|
def clear_polling_tick
|
|
166
178
|
synchronize do
|
|
167
|
-
@pollings.delete(
|
|
179
|
+
@pollings.delete(fiber_id)
|
|
168
180
|
end
|
|
169
181
|
end
|
|
170
182
|
|
|
171
183
|
# Update the processing tick time
|
|
172
184
|
def mark_consumption_tick
|
|
173
185
|
synchronize do
|
|
174
|
-
@consumptions[
|
|
186
|
+
@consumptions[fiber_id] = monotonic_now
|
|
175
187
|
end
|
|
176
188
|
end
|
|
177
189
|
|
|
178
|
-
# Clear current
|
|
190
|
+
# Clear current fiber consumption time tracker
|
|
179
191
|
def clear_consumption_tick
|
|
180
192
|
synchronize do
|
|
181
|
-
@consumptions.delete(
|
|
193
|
+
@consumptions.delete(fiber_id)
|
|
182
194
|
end
|
|
183
195
|
end
|
|
184
196
|
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Karafka
|
|
4
|
+
module Processing
|
|
5
|
+
# Consumer-group-specific processing components (driven by rebalance callbacks and partition
|
|
6
|
+
# ticks). Parallel `ShareGroups` will live next to this namespace once KIP-932 lands.
|
|
7
|
+
module ConsumerGroups
|
|
8
|
+
# Basic coordinator that allows us to provide coordination objects into consumers.
|
|
9
|
+
#
|
|
10
|
+
# This is a wrapping layer to simplify management of work to be handled around consumption.
|
|
11
|
+
#
|
|
12
|
+
# @note This coordinator needs to be thread safe. Some operations are performed only in the
|
|
13
|
+
# listener thread, but we go with thread-safe by default for all not to worry about potential
|
|
14
|
+
# future mistakes.
|
|
15
|
+
class Coordinator
|
|
16
|
+
extend Forwardable
|
|
17
|
+
include Core::Helpers::Time
|
|
18
|
+
|
|
19
|
+
attr_reader :pause_tracker, :seek_offset, :topic, :partition
|
|
20
|
+
|
|
21
|
+
# This can be set directly on the listener because it can be triggered on first run without
|
|
22
|
+
# any messages
|
|
23
|
+
attr_accessor :eofed
|
|
24
|
+
|
|
25
|
+
# Last polled at time set based on the incoming last poll time
|
|
26
|
+
attr_accessor :last_polled_at
|
|
27
|
+
|
|
28
|
+
def_delegators :@pause_tracker, :attempt, :paused?
|
|
29
|
+
|
|
30
|
+
# @param topic [Karafka::Routing::Topic]
|
|
31
|
+
# @param partition [Integer]
|
|
32
|
+
# @param pause_tracker [Karafka::TimeTrackers::Pause] pause tracker for given topic partition
|
|
33
|
+
def initialize(topic, partition, pause_tracker)
|
|
34
|
+
@topic = topic
|
|
35
|
+
@partition = partition
|
|
36
|
+
@pause_tracker = pause_tracker
|
|
37
|
+
@revoked = false
|
|
38
|
+
@consumptions = {}
|
|
39
|
+
@running_jobs = Hash.new { |h, k| h[k] = 0 }
|
|
40
|
+
@manual_pause = false
|
|
41
|
+
@manual_seek = false
|
|
42
|
+
@mutex = Mutex.new
|
|
43
|
+
@marked = false
|
|
44
|
+
@failure = false
|
|
45
|
+
@eofed = false
|
|
46
|
+
@changed_at = monotonic_now
|
|
47
|
+
@last_polled_at = @changed_at
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Starts the coordinator for given consumption jobs
|
|
51
|
+
# @param messages [Array<Karafka::Messages::Message>] batch of message for which we are
|
|
52
|
+
# going to coordinate work. Not used with regular coordinator.
|
|
53
|
+
def start(messages)
|
|
54
|
+
@failure = false
|
|
55
|
+
@running_jobs[:consume] = 0
|
|
56
|
+
# We need to clear the consumption results hash here, otherwise we could end up storing
|
|
57
|
+
# consumption results of consumer instances we no longer control
|
|
58
|
+
@consumptions.clear
|
|
59
|
+
|
|
60
|
+
# When starting to run, no pause is expected and no manual pause as well
|
|
61
|
+
@manual_pause = false
|
|
62
|
+
|
|
63
|
+
# No user invoked seeks on a new run
|
|
64
|
+
@manual_seek = false
|
|
65
|
+
|
|
66
|
+
# We set it on the first encounter and never again, because then the offset setting
|
|
67
|
+
# should be up to the consumers logic (our or the end user)
|
|
68
|
+
# Seek offset needs to be always initialized as for case where manual offset management
|
|
69
|
+
# is turned on, we need to have reference to the first offset even in case of running
|
|
70
|
+
# multiple batches without marking any messages as consumed. Rollback needs to happen to
|
|
71
|
+
# the last place we know of or the last message + 1 that was marked
|
|
72
|
+
#
|
|
73
|
+
# It is however worth keeping in mind, that this may need to be used with `#marked?` to
|
|
74
|
+
# make sure that the first offset is an offset that has been marked.
|
|
75
|
+
@seek_offset ||= messages.first.offset
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @param offset [Integer] message offset
|
|
79
|
+
def seek_offset=(offset)
|
|
80
|
+
synchronize do
|
|
81
|
+
@marked = true
|
|
82
|
+
@seek_offset = offset
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Increases number of jobs that we handle with this coordinator
|
|
87
|
+
# @param job_type [Symbol] type of job that we want to increment
|
|
88
|
+
def increment(job_type)
|
|
89
|
+
synchronize do
|
|
90
|
+
@running_jobs[job_type] += 1
|
|
91
|
+
@changed_at = monotonic_now
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Decrements number of jobs we handle at the moment
|
|
96
|
+
# @param job_type [Symbol] type of job that we want to decrement
|
|
97
|
+
def decrement(job_type)
|
|
98
|
+
synchronize do
|
|
99
|
+
@running_jobs[job_type] -= 1
|
|
100
|
+
@changed_at = monotonic_now
|
|
101
|
+
|
|
102
|
+
return @running_jobs[job_type] unless @running_jobs[job_type].negative?
|
|
103
|
+
|
|
104
|
+
# This should never happen. If it does, something is heavily out of sync. Please reach
|
|
105
|
+
# out to us if you encounter this
|
|
106
|
+
raise Karafka::Errors::InvalidCoordinatorStateError, "Was zero before decrementation"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Is all the consumption done and finished successfully for this coordinator
|
|
111
|
+
# We do not say we're successful until all work is done, because running work may still
|
|
112
|
+
# crash.
|
|
113
|
+
# @note This is only used for consume synchronization
|
|
114
|
+
def success?
|
|
115
|
+
synchronize do
|
|
116
|
+
@running_jobs[:consume].zero? && @consumptions.values.all?(&:success?)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Mark given consumption on consumer as successful
|
|
121
|
+
# @param consumer [Karafka::BaseConsumer] consumer that finished successfully
|
|
122
|
+
def success!(consumer)
|
|
123
|
+
synchronize do
|
|
124
|
+
consumption(consumer).success!
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Mark given consumption on consumer as failed
|
|
129
|
+
# @param consumer [Karafka::BaseConsumer] consumer that failed
|
|
130
|
+
# @param error [StandardError] error that occurred
|
|
131
|
+
def failure!(consumer, error)
|
|
132
|
+
synchronize do
|
|
133
|
+
@failure = true
|
|
134
|
+
consumption(consumer).failure!(error)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# @return [Boolean] true if any of work we were running failed
|
|
139
|
+
def failure?
|
|
140
|
+
@failure
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Marks given coordinator for processing group as revoked
|
|
144
|
+
#
|
|
145
|
+
# This is invoked in two places:
|
|
146
|
+
# - from the main listener loop when we detect revoked partitions
|
|
147
|
+
# - from the consumer in case checkpointing fails
|
|
148
|
+
#
|
|
149
|
+
# This means, we can end up having consumer being aware that it was revoked prior to the
|
|
150
|
+
# listener loop dispatching the revocation job. It is ok, as effectively nothing will be
|
|
151
|
+
# processed until revocation jobs are done.
|
|
152
|
+
def revoke
|
|
153
|
+
synchronize { @revoked = true }
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# @return [Boolean] is the partition we are processing revoked or not
|
|
157
|
+
def revoked?
|
|
158
|
+
@revoked
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# @return [Boolean] did we reach end of partition when polling data
|
|
162
|
+
def eofed?
|
|
163
|
+
@eofed
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# @return [Boolean] was the new seek offset assigned at least once. This is needed because
|
|
167
|
+
# by default we assign seek offset of a first message ever, however this is insufficient
|
|
168
|
+
# for DLQ in a scenario where the first message would be broken. We would never move
|
|
169
|
+
# out of it and would end up in an endless loop.
|
|
170
|
+
def marked?
|
|
171
|
+
@marked
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Store in the coordinator info, that this pause was done manually by the end user and not
|
|
175
|
+
# by the system itself
|
|
176
|
+
def manual_pause
|
|
177
|
+
@manual_pause = true
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# @return [Boolean] are we in a pause that was initiated by the user
|
|
181
|
+
def manual_pause?
|
|
182
|
+
paused? && @manual_pause
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Marks seek as manual for coordination purposes
|
|
186
|
+
def manual_seek
|
|
187
|
+
@manual_seek = true
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# @return [Boolean] did a user invoke seek in the current operations scope
|
|
191
|
+
def manual_seek?
|
|
192
|
+
@manual_seek
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# @param consumer [Object] karafka consumer (normal or pro)
|
|
196
|
+
# @return [Karafka::Processing::Result] result object which we can use to indicate
|
|
197
|
+
# consumption processing state.
|
|
198
|
+
def consumption(consumer)
|
|
199
|
+
@consumptions[consumer] ||= Processing::Result.new
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Allows to run synchronized (locked) code that can operate only from a given thread
|
|
203
|
+
#
|
|
204
|
+
# @note We check if mutex is not owned already by the current thread so we won't end up with
|
|
205
|
+
# a deadlock in case user runs coordinated code from inside of his own lock
|
|
206
|
+
#
|
|
207
|
+
# @note This is internal and should **not** be used to synchronize user-facing code.
|
|
208
|
+
# Otherwise user indirectly could cause deadlocks or prolonged locks by running his logic.
|
|
209
|
+
# This can and should however be used for multi-thread strategy applications and other
|
|
210
|
+
# internal operations locks.
|
|
211
|
+
def synchronize(&)
|
|
212
|
+
if @mutex.owned?
|
|
213
|
+
yield
|
|
214
|
+
else
|
|
215
|
+
@mutex.synchronize(&)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|