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,106 @@
|
|
|
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 Processing
|
|
34
|
+
# Consumer-group-specific Pro processing components (driven by rebalance callbacks and
|
|
35
|
+
# partition ticks). Parallel `ShareGroups` will live next to this namespace once KIP-932
|
|
36
|
+
# lands.
|
|
37
|
+
module ConsumerGroups
|
|
38
|
+
# Selector of appropriate processing strategy matching topic combinations
|
|
39
|
+
# When using Karafka Pro, there is a different set of strategies than for regular, as
|
|
40
|
+
# there are different features.
|
|
41
|
+
class StrategySelector
|
|
42
|
+
attr_reader :strategies
|
|
43
|
+
|
|
44
|
+
# Strategies that we support in the Pro offering They can be combined
|
|
45
|
+
SUPPORTED_FEATURES = %i[
|
|
46
|
+
active_job
|
|
47
|
+
long_running_job
|
|
48
|
+
manual_offset_management
|
|
49
|
+
virtual_partitions
|
|
50
|
+
dead_letter_queue
|
|
51
|
+
filtering
|
|
52
|
+
].freeze
|
|
53
|
+
|
|
54
|
+
# Initializes the strategy selector and preloads all strategies
|
|
55
|
+
def initialize
|
|
56
|
+
# Preload the strategies
|
|
57
|
+
# We load them once for performance reasons not to do too many lookups
|
|
58
|
+
@strategies = find_all
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @param topic [Karafka::Routing::Topic] topic with settings based on which we find
|
|
62
|
+
# the strategy
|
|
63
|
+
# @return [Module] module with proper strategy
|
|
64
|
+
def find(topic)
|
|
65
|
+
feature_set = SUPPORTED_FEATURES.map do |feature_name|
|
|
66
|
+
topic.public_send("#{feature_name}?") ? feature_name : nil
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
feature_set.compact!
|
|
70
|
+
feature_set.sort!
|
|
71
|
+
|
|
72
|
+
@strategies.find do |strategy|
|
|
73
|
+
strategy::FEATURES.sort == feature_set
|
|
74
|
+
end || raise(Errors::StrategyNotFoundError, topic.name)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
|
|
79
|
+
# @return [Array<Module>] all available strategies
|
|
80
|
+
def find_all
|
|
81
|
+
scopes = [Strategies]
|
|
82
|
+
modules = Strategies.constants
|
|
83
|
+
|
|
84
|
+
modules.each do |const|
|
|
85
|
+
scopes << Strategies.const_get(const)
|
|
86
|
+
modules += scopes.last.constants
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
scopes.flat_map do |scope|
|
|
90
|
+
modules.map do |const|
|
|
91
|
+
next if const == :FEATURES
|
|
92
|
+
next unless scope.const_defined?(const)
|
|
93
|
+
|
|
94
|
+
candidate = scope.const_get(const)
|
|
95
|
+
|
|
96
|
+
next unless candidate.const_defined?(:FEATURES)
|
|
97
|
+
|
|
98
|
+
candidate
|
|
99
|
+
end
|
|
100
|
+
end.uniq.compact
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
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 Processing
|
|
34
|
+
# Consumer-group-specific Pro processing components (driven by rebalance callbacks and
|
|
35
|
+
# partition ticks). Parallel `ShareGroups` will live next to this namespace once KIP-932
|
|
36
|
+
# lands.
|
|
37
|
+
module ConsumerGroups
|
|
38
|
+
# Uses the jobs queue API to lock (pause) and unlock (resume) operations of a given
|
|
39
|
+
# subscription group. It is abstracted away from jobs queue on this layer because we do
|
|
40
|
+
# not want to introduce jobs queue as a concept to the consumers layer
|
|
41
|
+
class SubscriptionGroupsCoordinator
|
|
42
|
+
include Singleton
|
|
43
|
+
|
|
44
|
+
# @param subscription_group [Karafka::Routing::SubscriptionGroup] subscription group we
|
|
45
|
+
# want to pause
|
|
46
|
+
# @param lock_id [Object] key we want to use if we want to set multiple locks on the same
|
|
47
|
+
# subscription group
|
|
48
|
+
def pause(subscription_group, lock_id = nil, **)
|
|
49
|
+
jobs_queue.lock_async(
|
|
50
|
+
subscription_group.id,
|
|
51
|
+
lock_id,
|
|
52
|
+
**
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @param subscription_group [Karafka::Routing::SubscriptionGroup] subscription group we
|
|
57
|
+
# want to resume
|
|
58
|
+
# @param lock_id [Object] lock id (if it was used to pause)
|
|
59
|
+
def resume(subscription_group, lock_id = nil)
|
|
60
|
+
jobs_queue.unlock_async(subscription_group.id, lock_id)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
# @return [Karafka::Pro::Processing::JobsQueue]
|
|
66
|
+
def jobs_queue
|
|
67
|
+
@jobs_queue ||= Karafka::Server.jobs_queue
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
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 Processing
|
|
34
|
+
# Consumer-group-specific Pro processing components (driven by rebalance callbacks and
|
|
35
|
+
# partition ticks). Parallel `ShareGroups` will live next to this namespace once KIP-932
|
|
36
|
+
# lands.
|
|
37
|
+
module ConsumerGroups
|
|
38
|
+
module VirtualPartitions
|
|
39
|
+
module Distributors
|
|
40
|
+
# Balanced distributor that groups messages by partition key
|
|
41
|
+
# and processes larger groups first while maintaining message order within groups
|
|
42
|
+
class Balanced < Base
|
|
43
|
+
# Distributes messages to virtual partitions ensuring balanced load across workers
|
|
44
|
+
# by grouping messages by partition key and assigning larger groups first
|
|
45
|
+
# @param messages [Array<Karafka::Messages::Message>]
|
|
46
|
+
# @return [Hash{Integer => Array<Karafka::Messages::Message>}] hash with group ids as
|
|
47
|
+
# keys and message groups as values
|
|
48
|
+
def call(messages)
|
|
49
|
+
# Group messages by partition key
|
|
50
|
+
key_groupings = messages.group_by { |msg| config.partitioner.call(msg) }
|
|
51
|
+
|
|
52
|
+
worker_loads = Array.new(config.max_partitions, 0)
|
|
53
|
+
worker_assignments = Array.new(config.max_partitions) { [] }
|
|
54
|
+
|
|
55
|
+
# Sort keys by workload in descending order
|
|
56
|
+
sorted_keys = key_groupings.keys.sort_by { |key| -key_groupings[key].size }
|
|
57
|
+
|
|
58
|
+
# Assign each key to the worker with the least current load
|
|
59
|
+
sorted_keys.each do |key|
|
|
60
|
+
# Find worker with minimum current load
|
|
61
|
+
min_load_worker = worker_loads.each_with_index.min_by { |load, _| load }[1]
|
|
62
|
+
messages = key_groupings[key]
|
|
63
|
+
|
|
64
|
+
# Assign this key to that worker
|
|
65
|
+
worker_assignments[min_load_worker] += messages
|
|
66
|
+
worker_loads[min_load_worker] += messages.size
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Combine messages for each worker and sort by offset
|
|
70
|
+
worker_assignments
|
|
71
|
+
.each_with_index
|
|
72
|
+
.reject { |group_messages, _| group_messages.empty? }
|
|
73
|
+
.map! { |group_messages, index| [index, group_messages.sort_by!(&:offset)] }
|
|
74
|
+
.to_h
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
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 Processing
|
|
34
|
+
# Consumer-group-specific Pro processing components (driven by rebalance callbacks and
|
|
35
|
+
# partition ticks). Parallel `ShareGroups` will live next to this namespace once KIP-932
|
|
36
|
+
# lands.
|
|
37
|
+
module ConsumerGroups
|
|
38
|
+
# Processing components for virtual partitions
|
|
39
|
+
module VirtualPartitions
|
|
40
|
+
# Distributors for virtual partitions
|
|
41
|
+
module Distributors
|
|
42
|
+
# Base class for all virtual partition distributors
|
|
43
|
+
class Base
|
|
44
|
+
# @param config [Karafka::Pro::Routing::Features::ConsumerGroups::VirtualPartitions::Config]
|
|
45
|
+
def initialize(config)
|
|
46
|
+
@config = config
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
# @return [Karafka::Pro::Routing::Features::ConsumerGroups::VirtualPartitions::Config]
|
|
52
|
+
attr_reader :config
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -31,39 +31,24 @@
|
|
|
31
31
|
module Karafka
|
|
32
32
|
module Pro
|
|
33
33
|
module Processing
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return if revoked?
|
|
53
|
-
|
|
54
|
-
if coordinator.success?
|
|
55
|
-
coordinator.pause_tracker.reset
|
|
56
|
-
|
|
57
|
-
return if coordinator.manual_pause?
|
|
58
|
-
|
|
59
|
-
mark_as_consumed(last_group_message)
|
|
60
|
-
|
|
61
|
-
handle_post_filtering
|
|
62
|
-
else
|
|
63
|
-
apply_dlq_flow do
|
|
64
|
-
dispatch_if_needed_and_mark_as_consumed
|
|
65
|
-
end
|
|
66
|
-
end
|
|
34
|
+
# Consumer-group-specific Pro processing components (driven by rebalance callbacks and
|
|
35
|
+
# partition ticks). Parallel `ShareGroups` will live next to this namespace once KIP-932
|
|
36
|
+
# lands.
|
|
37
|
+
module ConsumerGroups
|
|
38
|
+
module VirtualPartitions
|
|
39
|
+
module Distributors
|
|
40
|
+
# Consistent distributor that ensures messages with the same partition key
|
|
41
|
+
# are always processed in the same virtual partition
|
|
42
|
+
class Consistent < Base
|
|
43
|
+
# Distributes messages ensuring consistent routing where messages with the same
|
|
44
|
+
# partition key always go to the same virtual partition
|
|
45
|
+
# @param messages [Array<Karafka::Messages::Message>]
|
|
46
|
+
# @return [Hash{Integer => Array<Karafka::Messages::Message>}] hash with group ids as
|
|
47
|
+
# keys and message groups as values
|
|
48
|
+
def call(messages)
|
|
49
|
+
messages
|
|
50
|
+
.group_by { |msg| config.reducer.call(config.partitioner.call(msg)) }
|
|
51
|
+
.to_h
|
|
67
52
|
end
|
|
68
53
|
end
|
|
69
54
|
end
|
|
@@ -31,68 +31,10 @@
|
|
|
31
31
|
module Karafka
|
|
32
32
|
module Pro
|
|
33
33
|
module Processing
|
|
34
|
+
# Backwards-compatible aliases for filter classes moved under ConsumerGroups.
|
|
34
35
|
module Filters
|
|
35
|
-
# Base
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
# Due to the fact, that filters can limit data in such a way, that we need to pause or
|
|
39
|
-
# seek (throttling for example), the api is not just "remove some things from batch" but
|
|
40
|
-
# also provides ways to control the post-filtering operations that may be needed.
|
|
41
|
-
class Base
|
|
42
|
-
# @return [Karafka::Messages::Message, nil] the message that we want to use as a cursor
|
|
43
|
-
# one to pause or seek or nil if not applicable.
|
|
44
|
-
attr_reader :cursor
|
|
45
|
-
|
|
46
|
-
include Karafka::Core::Helpers::Time
|
|
47
|
-
|
|
48
|
-
# Initializes the filter as not yet applied
|
|
49
|
-
def initialize
|
|
50
|
-
@applied = false
|
|
51
|
-
@cursor = nil
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# @param messages [Array<Karafka::Messages::Message>] array with messages. Please keep
|
|
55
|
-
# in mind, this may already be partial due to execution of previous filters.
|
|
56
|
-
def apply!(messages)
|
|
57
|
-
raise NotImplementedError, "Implement in a subclass"
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# @return [Symbol] filter post-execution action on consumer. Either `:skip`, `:pause` or
|
|
61
|
-
# `:seek`.
|
|
62
|
-
def action
|
|
63
|
-
:skip
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# @return [Boolean] did this filter change messages in any way
|
|
67
|
-
def applied?
|
|
68
|
-
@applied
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# @return [Integer, nil] default timeout for pausing (if applicable) or nil if not
|
|
72
|
-
# @note Please do not return `0` when your filter is not pausing as it may interact
|
|
73
|
-
# with other filters that want to pause.
|
|
74
|
-
def timeout
|
|
75
|
-
nil
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# @return [Boolean] should we use the cursor value to mark as consumed. If any of the
|
|
79
|
-
# filters returns true, we return lowers applicable cursor value (if any)
|
|
80
|
-
def mark_as_consumed?
|
|
81
|
-
false
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# @return [Symbol] `:mark_as_consumed` or `:mark_as_consumed!`. Applicable only if
|
|
85
|
-
# marking is requested
|
|
86
|
-
def marking_method
|
|
87
|
-
:mark_as_consumed
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# @return [Karafka::Messages::Message, nil] cursor message for marking or nil if no
|
|
91
|
-
# marking
|
|
92
|
-
def marking_cursor
|
|
93
|
-
cursor
|
|
94
|
-
end
|
|
95
|
-
end
|
|
36
|
+
# @see ConsumerGroups::Filters::Base
|
|
37
|
+
Base = ConsumerGroups::Filters::Base
|
|
96
38
|
end
|
|
97
39
|
end
|
|
98
40
|
end
|
|
@@ -31,63 +31,8 @@
|
|
|
31
31
|
module Karafka
|
|
32
32
|
module Pro
|
|
33
33
|
module Processing
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
# @param topic [String] topic name
|
|
37
|
-
# @param messages [Array<Karafka::Messages::Message>] karafka messages
|
|
38
|
-
# @param coordinator [Karafka::Pro::Processing::Coordinator] processing coordinator that
|
|
39
|
-
# will be used with those messages
|
|
40
|
-
# @yieldparam [Integer] group id
|
|
41
|
-
# @yieldparam [Array<Karafka::Messages::Message>] karafka messages
|
|
42
|
-
def call(topic, messages, coordinator)
|
|
43
|
-
ktopic = @subscription_group.topics.find(topic)
|
|
44
|
-
|
|
45
|
-
vps = ktopic.virtual_partitions
|
|
46
|
-
|
|
47
|
-
# We only partition work if we have:
|
|
48
|
-
# - a virtual partitioner
|
|
49
|
-
# - more than one thread to process the data
|
|
50
|
-
# - collective is not collapsed via coordinator
|
|
51
|
-
# - none of the partitioner executions raised an error
|
|
52
|
-
#
|
|
53
|
-
# With one thread it is not worth partitioning the work as the work itself will be
|
|
54
|
-
# assigned to one thread (pointless work)
|
|
55
|
-
#
|
|
56
|
-
# We collapse the partitioning on errors because we "regain" full ordering on a batch
|
|
57
|
-
# that potentially contains the data that caused the error.
|
|
58
|
-
#
|
|
59
|
-
# This is great because it allows us to run things without the parallelization that adds
|
|
60
|
-
# a bit of uncertainty and allows us to use DLQ and safely skip messages if needed.
|
|
61
|
-
if vps.active? && vps.max_partitions > 1 && !coordinator.collapsed?
|
|
62
|
-
# If we cannot virtualize even one message from a given batch due to user errors, we
|
|
63
|
-
# reduce the whole set into one partition and emit error. This should still allow for
|
|
64
|
-
# user flow but should mitigate damages by not virtualizing
|
|
65
|
-
begin
|
|
66
|
-
groupings = vps.distributor.call(messages)
|
|
67
|
-
rescue => e
|
|
68
|
-
# This should not happen. If you are seeing this it means your partitioner code
|
|
69
|
-
# failed and raised an error. We highly recommend mitigating partitioner level errors
|
|
70
|
-
# on the user side because this type of collapse should be considered a last resort
|
|
71
|
-
Karafka.monitor.instrument(
|
|
72
|
-
"error.occurred",
|
|
73
|
-
caller: self,
|
|
74
|
-
error: e,
|
|
75
|
-
messages: messages,
|
|
76
|
-
type: "virtual_partitions.partitioner.error"
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
groupings = { 0 => messages }
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
groupings.each do |key, messages_group|
|
|
83
|
-
yield(key, messages_group)
|
|
84
|
-
end
|
|
85
|
-
else
|
|
86
|
-
# When no virtual partitioner, works as regular one
|
|
87
|
-
yield(0, messages)
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
34
|
+
# @see ConsumerGroups::Partitioner
|
|
35
|
+
Partitioner = ConsumerGroups::Partitioner
|
|
91
36
|
end
|
|
92
37
|
end
|
|
93
38
|
end
|
|
@@ -59,7 +59,8 @@ module Karafka
|
|
|
59
59
|
# Runs the consumption jobs scheduling flow under a mutex
|
|
60
60
|
#
|
|
61
61
|
# @param jobs_array
|
|
62
|
-
# [Array<Karafka::Processing::Jobs::Consume,
|
|
62
|
+
# [Array<Karafka::Processing::ConsumerGroups::Jobs::Consume,
|
|
63
|
+
# Karafka::Pro::Processing::ConsumerGroups::Jobs::ConsumeNonBlocking>]
|
|
63
64
|
# jobs for scheduling
|
|
64
65
|
def on_schedule_consumption(jobs_array)
|
|
65
66
|
@mutex.synchronize do
|
|
@@ -70,7 +71,8 @@ module Karafka
|
|
|
70
71
|
# Should schedule the consumption jobs
|
|
71
72
|
#
|
|
72
73
|
# @param _jobs_array
|
|
73
|
-
# [Array<Karafka::Processing::Jobs::Consume,
|
|
74
|
+
# [Array<Karafka::Processing::ConsumerGroups::Jobs::Consume,
|
|
75
|
+
# Karafka::Pro::Processing::ConsumerGroups::Jobs::ConsumeNonBlocking>]
|
|
74
76
|
# jobs for scheduling
|
|
75
77
|
def schedule_consumption(_jobs_array)
|
|
76
78
|
raise NotImplementedError, "Implement in a subclass"
|
|
@@ -79,7 +81,8 @@ module Karafka
|
|
|
79
81
|
# Runs the revocation jobs scheduling flow under a mutex
|
|
80
82
|
#
|
|
81
83
|
# @param jobs_array
|
|
82
|
-
# [Array<Karafka::Processing::Jobs::Revoked,
|
|
84
|
+
# [Array<Karafka::Processing::ConsumerGroups::Jobs::Revoked,
|
|
85
|
+
# Karafka::Pro::Processing::ConsumerGroups::Jobs::RevokedNonBlocking>]
|
|
83
86
|
# jobs for scheduling
|
|
84
87
|
def on_schedule_revocation(jobs_array)
|
|
85
88
|
@mutex.synchronize do
|
|
@@ -89,7 +92,7 @@ module Karafka
|
|
|
89
92
|
|
|
90
93
|
# Runs the shutdown jobs scheduling flow under a mutex
|
|
91
94
|
#
|
|
92
|
-
# @param jobs_array [Array<Karafka::Processing::Jobs::Shutdown>] jobs for scheduling
|
|
95
|
+
# @param jobs_array [Array<Karafka::Processing::ConsumerGroups::Jobs::Shutdown>] jobs for scheduling
|
|
93
96
|
def on_schedule_shutdown(jobs_array)
|
|
94
97
|
@mutex.synchronize do
|
|
95
98
|
schedule_shutdown(jobs_array)
|
|
@@ -98,7 +101,7 @@ module Karafka
|
|
|
98
101
|
|
|
99
102
|
# Runs the idle jobs scheduling flow under a mutex
|
|
100
103
|
#
|
|
101
|
-
# @param jobs_array [Array<Karafka::Processing::Jobs::Idle>] jobs for scheduling
|
|
104
|
+
# @param jobs_array [Array<Karafka::Processing::ConsumerGroups::Jobs::Idle>] jobs for scheduling
|
|
102
105
|
def on_schedule_idle(jobs_array)
|
|
103
106
|
@mutex.synchronize do
|
|
104
107
|
schedule_idle(jobs_array)
|
|
@@ -108,7 +111,8 @@ module Karafka
|
|
|
108
111
|
# Runs the periodic jobs scheduling flow under a mutex
|
|
109
112
|
#
|
|
110
113
|
# @param jobs_array
|
|
111
|
-
# [Array<Processing::Jobs::Periodic,
|
|
114
|
+
# [Array<Karafka::Pro::Processing::ConsumerGroups::Jobs::Periodic,
|
|
115
|
+
# Karafka::Pro::Processing::ConsumerGroups::Jobs::PeriodicNonBlocking>]
|
|
112
116
|
# jobs for scheduling
|
|
113
117
|
def on_schedule_periodic(jobs_array)
|
|
114
118
|
@mutex.synchronize do
|
|
@@ -49,7 +49,8 @@ module Karafka
|
|
|
49
49
|
# Schedules jobs in the LJF order for consumption
|
|
50
50
|
#
|
|
51
51
|
# @param jobs_array
|
|
52
|
-
# [Array<Karafka::Processing::Jobs::Consume,
|
|
52
|
+
# [Array<Karafka::Processing::ConsumerGroups::Jobs::Consume,
|
|
53
|
+
# Karafka::Pro::Processing::ConsumerGroups::Jobs::ConsumeNonBlocking>]
|
|
53
54
|
# jobs for scheduling
|
|
54
55
|
def on_schedule_consumption(jobs_array)
|
|
55
56
|
perf_tracker = Instrumentation::PerformanceTracker.instance
|
|
@@ -85,8 +86,7 @@ module Karafka
|
|
|
85
86
|
alias_method :on_schedule_periodic, :schedule_fifo
|
|
86
87
|
alias_method :on_schedule_eofed, :schedule_fifo
|
|
87
88
|
|
|
88
|
-
# This scheduler does not have anything to manage as it is a pass through and has no
|
|
89
|
-
# state
|
|
89
|
+
# This scheduler does not have anything to manage as it is a pass through and has no state
|
|
90
90
|
def on_manage
|
|
91
91
|
nil
|
|
92
92
|
end
|
|
@@ -101,10 +101,11 @@ module Karafka
|
|
|
101
101
|
private
|
|
102
102
|
|
|
103
103
|
# @param perf_tracker [PerformanceTracker]
|
|
104
|
-
# @param job [Karafka::Processing::Jobs::Consume] job we will be
|
|
104
|
+
# @param job [Karafka::Processing::ConsumerGroups::Jobs::Consume] job we will be
|
|
105
|
+
# processing
|
|
105
106
|
# @return [Numeric] estimated cost of processing this job
|
|
106
107
|
def processing_cost(perf_tracker, job)
|
|
107
|
-
if job.is_a?(::Karafka::Processing::Jobs::Consume)
|
|
108
|
+
if job.is_a?(::Karafka::Processing::ConsumerGroups::Jobs::Consume)
|
|
108
109
|
messages = job.messages
|
|
109
110
|
message = messages.first
|
|
110
111
|
|
|
@@ -93,8 +93,7 @@ module Karafka
|
|
|
93
93
|
|
|
94
94
|
@replaying = false
|
|
95
95
|
|
|
96
|
-
# When there is nothing to replay and synchronize, we can just save the state and
|
|
97
|
-
# proceed
|
|
96
|
+
# When there is nothing to replay and synchronize, we can just save the state and proceed
|
|
98
97
|
if @catchup_commands.empty? && @catchup_schedule.nil?
|
|
99
98
|
snapshot
|
|
100
99
|
|
|
@@ -32,26 +32,28 @@ module Karafka
|
|
|
32
32
|
module Pro
|
|
33
33
|
module Routing
|
|
34
34
|
module Features
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
module ConsumerGroups
|
|
36
|
+
class ActiveJob < Base
|
|
37
|
+
# Pro ActiveJob builder expansions
|
|
38
|
+
module Builder
|
|
39
|
+
# This method simplifies routes definition for ActiveJob patterns / queues by
|
|
40
|
+
# auto-injecting the consumer class and other things needed
|
|
41
|
+
#
|
|
42
|
+
# @param regexp_or_name [String, Symbol, Regexp] pattern name or regexp to use
|
|
43
|
+
# auto-generated regexp names
|
|
44
|
+
# @param regexp [Regexp, nil] activejob regexp pattern or nil when regexp is provided
|
|
45
|
+
# as the first argument
|
|
46
|
+
# @param block [Proc] block that we can use for some extra configuration
|
|
47
|
+
def active_job_pattern(regexp_or_name, regexp = nil, &block)
|
|
48
|
+
pattern(regexp_or_name, regexp) do
|
|
49
|
+
consumer App.config.internal.active_job.consumer_class
|
|
50
|
+
active_job true
|
|
51
|
+
manual_offset_management true
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
next unless block
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
instance_eval(&block)
|
|
56
|
+
end
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
59
|
end
|