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
|
@@ -1,197 +0,0 @@
|
|
|
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
|
-
# Pro coordinator that provides extra orchestration methods useful for parallel processing
|
|
35
|
-
# within the same partition
|
|
36
|
-
class Coordinator < Karafka::Processing::Coordinator
|
|
37
|
-
extend Forwardable
|
|
38
|
-
include Helpers::ConfigImporter.new(
|
|
39
|
-
errors_tracker_class: %i[internal processing errors_tracker_class]
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
def_delegators :@collapser, :collapsed?, :collapse_until!
|
|
43
|
-
|
|
44
|
-
attr_reader :filter, :virtual_offset_manager, :shared_mutex, :errors_tracker
|
|
45
|
-
|
|
46
|
-
# @param args [Object] anything the base coordinator accepts
|
|
47
|
-
def initialize(*args)
|
|
48
|
-
super
|
|
49
|
-
|
|
50
|
-
@executed = []
|
|
51
|
-
@errors_tracker = errors_tracker_class.new(topic, partition)
|
|
52
|
-
@flow_mutex = Mutex.new
|
|
53
|
-
# Lock for user code synchronization
|
|
54
|
-
# We do not want to mix coordinator lock with the user lock not to create cases where
|
|
55
|
-
# user imposed lock would lock the internal operations of Karafka
|
|
56
|
-
# This shared lock can be used by the end user as it is not used internally by the
|
|
57
|
-
# framework and can be used for user-facing locking
|
|
58
|
-
@shared_mutex = Mutex.new
|
|
59
|
-
@collapser = Collapser.new
|
|
60
|
-
@filter = Coordinators::FiltersApplier.new(self)
|
|
61
|
-
|
|
62
|
-
return unless topic.virtual_partitions?
|
|
63
|
-
|
|
64
|
-
@virtual_offset_manager = Coordinators::VirtualOffsetManager.new(
|
|
65
|
-
topic.name,
|
|
66
|
-
partition,
|
|
67
|
-
topic.virtual_partitions.offset_metadata_strategy
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
# We register our own "internal" filter to support filtering of messages that were marked
|
|
71
|
-
# as consumed virtually
|
|
72
|
-
@filter.filters << Filters::VirtualLimiter.new(
|
|
73
|
-
@virtual_offset_manager,
|
|
74
|
-
@collapser
|
|
75
|
-
)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# Starts the coordination process
|
|
79
|
-
# @param messages [Array<Karafka::Messages::Message>] messages for which processing we are
|
|
80
|
-
# going to coordinate.
|
|
81
|
-
def start(messages)
|
|
82
|
-
super
|
|
83
|
-
|
|
84
|
-
@collapser.refresh!(messages.first.offset)
|
|
85
|
-
|
|
86
|
-
@filter.apply!(messages)
|
|
87
|
-
|
|
88
|
-
# Do not clear coordinator errors storage when we are retrying, so we can reference the
|
|
89
|
-
# errors that have happened during recovery. This can be useful for implementing custom
|
|
90
|
-
# flows. There can be more errors than one when running with virtual partitions so we
|
|
91
|
-
# need to make sure we collect them all. Under collapse when we reference a given
|
|
92
|
-
# consumer we should be able to get all the errors and not just first/last.
|
|
93
|
-
#
|
|
94
|
-
# @note We use zero as the attempt mark because we are not "yet" in the attempt 1
|
|
95
|
-
@errors_tracker.clear if attempt.zero?
|
|
96
|
-
@executed.clear
|
|
97
|
-
|
|
98
|
-
# We keep the old processed offsets until the collapsing is done and regular processing
|
|
99
|
-
# with virtualization is restored
|
|
100
|
-
@virtual_offset_manager.clear if topic.virtual_partitions? && !collapsed?
|
|
101
|
-
|
|
102
|
-
@last_message = messages.last
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Sets the consumer failure status and additionally starts the collapse until
|
|
106
|
-
#
|
|
107
|
-
# @param consumer [Karafka::BaseConsumer] consumer that failed
|
|
108
|
-
# @param error [StandardError] error from the failure
|
|
109
|
-
def failure!(consumer, error)
|
|
110
|
-
super
|
|
111
|
-
@errors_tracker << error
|
|
112
|
-
collapse_until!(@last_message.offset + 1)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# @return [Boolean] did any of the filters apply any logic that would cause use to run
|
|
116
|
-
# the filtering flow
|
|
117
|
-
def filtered?
|
|
118
|
-
@filter.applied?
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# @return [Boolean] is the coordinated work finished or not
|
|
122
|
-
# @note Used only in the consume operation context
|
|
123
|
-
def finished?
|
|
124
|
-
@running_jobs[:consume].zero?
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
# Runs synchronized code once for a collective of virtual partitions prior to work being
|
|
128
|
-
# enqueued
|
|
129
|
-
def on_enqueued
|
|
130
|
-
@flow_mutex.synchronize do
|
|
131
|
-
return unless executable?(:on_enqueued)
|
|
132
|
-
|
|
133
|
-
yield(@last_message)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Runs given code only once per all the coordinated jobs upon starting first of them
|
|
138
|
-
def on_started
|
|
139
|
-
@flow_mutex.synchronize do
|
|
140
|
-
return unless executable?(:on_started)
|
|
141
|
-
|
|
142
|
-
yield(@last_message)
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# Runs given code once when all the work that is suppose to be coordinated is finished
|
|
147
|
-
# It runs once per all the coordinated jobs and should be used to run any type of post
|
|
148
|
-
# jobs coordination processing execution
|
|
149
|
-
def on_finished
|
|
150
|
-
@flow_mutex.synchronize do
|
|
151
|
-
return unless finished?
|
|
152
|
-
return unless executable?(:on_finished)
|
|
153
|
-
|
|
154
|
-
yield(@last_message)
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
# Runs once after a partition is revoked
|
|
159
|
-
def on_revoked
|
|
160
|
-
@flow_mutex.synchronize do
|
|
161
|
-
return unless executable?(:on_revoked)
|
|
162
|
-
|
|
163
|
-
yield(@last_message)
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
# @param interval [Integer] milliseconds of activity
|
|
168
|
-
# @return [Boolean] was this partition in activity within last `interval` milliseconds
|
|
169
|
-
# @note Will return true also if currently active
|
|
170
|
-
def active_within?(interval)
|
|
171
|
-
# its always active if there's any job related to this coordinator that is still
|
|
172
|
-
# enqueued or running
|
|
173
|
-
return true if @running_jobs.values.any?(:positive?)
|
|
174
|
-
|
|
175
|
-
# Otherwise we check last time any job of this coordinator was active
|
|
176
|
-
@changed_at + interval > monotonic_now
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
private
|
|
180
|
-
|
|
181
|
-
# Checks if given action is executable once. If it is and true is returned, this method
|
|
182
|
-
# will return false next time it is used.
|
|
183
|
-
#
|
|
184
|
-
# @param action [Symbol] what action we want to perform
|
|
185
|
-
# @return [Boolean] true if we can
|
|
186
|
-
# @note This method needs to run behind a mutex.
|
|
187
|
-
def executable?(action)
|
|
188
|
-
return false if @executed.include?(action)
|
|
189
|
-
|
|
190
|
-
@executed << action
|
|
191
|
-
|
|
192
|
-
true
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
@@ -1,119 +0,0 @@
|
|
|
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
|
-
# Namespace for Pro coordinator related sub-components
|
|
35
|
-
module Coordinators
|
|
36
|
-
# Object used to track errors in between executions to be able to build error-type based
|
|
37
|
-
# recovery flows.
|
|
38
|
-
class ErrorsTracker
|
|
39
|
-
include Enumerable
|
|
40
|
-
|
|
41
|
-
# @return [Karafka::Routing::Topic] topic of this error tracker
|
|
42
|
-
attr_reader :topic
|
|
43
|
-
|
|
44
|
-
# @return [Integer] partition of this error tracker
|
|
45
|
-
attr_reader :partition
|
|
46
|
-
|
|
47
|
-
# @return [Hash]
|
|
48
|
-
attr_reader :counts
|
|
49
|
-
|
|
50
|
-
# @return [String]
|
|
51
|
-
attr_reader :trace_id
|
|
52
|
-
|
|
53
|
-
# Max errors we keep in memory.
|
|
54
|
-
# We do not want to keep more because for DLQ-less this would cause memory-leaks.
|
|
55
|
-
# We do however count per class for granular error counting
|
|
56
|
-
STORAGE_LIMIT = 100
|
|
57
|
-
|
|
58
|
-
private_constant :STORAGE_LIMIT
|
|
59
|
-
|
|
60
|
-
# @param topic [Karafka::Routing::Topic]
|
|
61
|
-
# @param partition [Integer]
|
|
62
|
-
# @param limit [Integer] max number of errors we want to keep for reference when
|
|
63
|
-
# implementing custom error handling.
|
|
64
|
-
# @note `limit` does not apply to the counts. They will work beyond the number of errors
|
|
65
|
-
# occurring
|
|
66
|
-
def initialize(topic, partition, limit: STORAGE_LIMIT)
|
|
67
|
-
@errors = []
|
|
68
|
-
@counts = Hash.new { |hash, key| hash[key] = 0 }
|
|
69
|
-
@topic = topic
|
|
70
|
-
@partition = partition
|
|
71
|
-
@limit = limit
|
|
72
|
-
@trace_id = SecureRandom.uuid
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Clears all the errors
|
|
76
|
-
def clear
|
|
77
|
-
@errors.clear
|
|
78
|
-
@counts.clear
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# @param error [StandardError] adds the error to the tracker
|
|
82
|
-
def <<(error)
|
|
83
|
-
@errors.shift if @errors.size >= @limit
|
|
84
|
-
@errors << error
|
|
85
|
-
@counts[error.class] += 1
|
|
86
|
-
@trace_id = SecureRandom.uuid
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# @return [Boolean] is the error tracker empty
|
|
90
|
-
def empty?
|
|
91
|
-
@errors.empty?
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# @return [Integer] number of elements
|
|
95
|
-
def size
|
|
96
|
-
# We use counts reference of all errors and not the `@errors` array because it allows
|
|
97
|
-
# us to go beyond the whole errors storage limit
|
|
98
|
-
@counts.values.sum
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# @return [StandardError, nil] last error that occurred or nil if no errors
|
|
102
|
-
def last
|
|
103
|
-
@errors.last
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# Iterates over errors
|
|
107
|
-
def each(&)
|
|
108
|
-
@errors.each(&)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
# @return [Array<StandardError>] array with all the errors that occurred
|
|
112
|
-
def all
|
|
113
|
-
@errors
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
@@ -1,152 +0,0 @@
|
|
|
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
|
-
module Coordinators
|
|
35
|
-
# Applier for all filters we want to have. Whether related to limiting messages based
|
|
36
|
-
# on the payload or any other things.
|
|
37
|
-
#
|
|
38
|
-
# From the outside world perspective, this encapsulates all the filters.
|
|
39
|
-
# This means that this is the API we expose as a single filter, allowing us to control
|
|
40
|
-
# the filtering via many filters easily.
|
|
41
|
-
class FiltersApplier
|
|
42
|
-
# @return [Array] registered filters array. Useful if we want to inject internal context
|
|
43
|
-
# aware filters.
|
|
44
|
-
attr_reader :filters
|
|
45
|
-
|
|
46
|
-
# @param coordinator [Pro::Coordinator] pro coordinator
|
|
47
|
-
def initialize(coordinator)
|
|
48
|
-
# Builds filters out of their factories
|
|
49
|
-
# We build it that way (providing topic and partition) because there may be a case
|
|
50
|
-
# where someone wants to have a specific logic that is per topic or partition. Like for
|
|
51
|
-
# example a case where there is a cache bypassing revocations for topic partition.
|
|
52
|
-
#
|
|
53
|
-
# We provide full Karafka routing topic here and not the name only, in case the filter
|
|
54
|
-
# would be customized based on other topic settings (like VPs, etc)
|
|
55
|
-
#
|
|
56
|
-
# This setup allows for biggest flexibility also because topic object holds the
|
|
57
|
-
# reference to the subscription group and consumer group
|
|
58
|
-
@filters = coordinator.topic.filtering.factories.map do |factory|
|
|
59
|
-
factory.call(coordinator.topic, coordinator.partition)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# @param messages [Array<Karafka::Messages::Message>] array with messages from the
|
|
64
|
-
# partition
|
|
65
|
-
def apply!(messages)
|
|
66
|
-
return unless active?
|
|
67
|
-
|
|
68
|
-
@filters.each { |filter| filter.apply!(messages) }
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# @return [Boolean] did we filter out any messages during filtering run
|
|
72
|
-
def applied?
|
|
73
|
-
return false unless active?
|
|
74
|
-
|
|
75
|
-
!applied.empty?
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# @return [Symbol] consumer post-filtering action that should be taken
|
|
79
|
-
def action
|
|
80
|
-
return :skip unless applied?
|
|
81
|
-
|
|
82
|
-
# The highest priority is on a potential backoff from any of the filters because it is
|
|
83
|
-
# the less risky (delay and continue later)
|
|
84
|
-
return :pause if applied.any? { |filter| filter.action == :pause }
|
|
85
|
-
|
|
86
|
-
# If none of the filters wanted to pause, we can check for any that would want to seek
|
|
87
|
-
# and if there is any, we can go with this strategy
|
|
88
|
-
return :seek if applied.any? { |filter| filter.action == :seek }
|
|
89
|
-
|
|
90
|
-
:skip
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# @return [Integer] minimum timeout we need to pause. This is the minimum for all the
|
|
94
|
-
# filters to satisfy all of them.
|
|
95
|
-
def timeout
|
|
96
|
-
applied.filter_map(&:timeout).min || 0
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# The first message we do need to get next time we poll. We use the minimum not to jump
|
|
100
|
-
# accidentally by over any.
|
|
101
|
-
# @return [Karafka::Messages::Message, nil] cursor message or nil if none
|
|
102
|
-
# @note Cursor message can also return the offset in the time format
|
|
103
|
-
def cursor
|
|
104
|
-
return nil unless active?
|
|
105
|
-
|
|
106
|
-
applied.filter_map(&:cursor).min_by(&:offset)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# @return [Boolean] did any of the filters requested offset storage during filter
|
|
110
|
-
# application
|
|
111
|
-
def mark_as_consumed?
|
|
112
|
-
# We can manage filtering offset only when user wanted that and there is a cursor
|
|
113
|
-
# to use
|
|
114
|
-
applied.any?(&:mark_as_consumed?) && cursor
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# @return [Symbol] `:mark_as_consumed` or `:mark_as_consumed!`
|
|
118
|
-
def marking_method
|
|
119
|
-
candidates = applied.map(&:marking_method)
|
|
120
|
-
|
|
121
|
-
return :mark_as_consumed! if candidates.include?(:mark_as_consumed!)
|
|
122
|
-
|
|
123
|
-
:mark_as_consumed
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
# The first (lowest) message we want to mark as consumed in marking. By default it uses
|
|
127
|
-
# same position as cursor in case user wants to mark same message as consumed as the
|
|
128
|
-
# one on which cursor action is applied.
|
|
129
|
-
# @return [Karafka::Messages::Message, nil] cursor marking message or nil if none
|
|
130
|
-
# @note It should not return position in time format, only numerical offset
|
|
131
|
-
def marking_cursor
|
|
132
|
-
return nil unless active?
|
|
133
|
-
|
|
134
|
-
applied.filter_map(&:marking_cursor).min_by(&:offset)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
private
|
|
138
|
-
|
|
139
|
-
# @return [Boolean] is filtering active
|
|
140
|
-
def active?
|
|
141
|
-
!@filters.empty?
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# @return [Array<Object>] filters that applied any sort of messages limiting
|
|
145
|
-
def applied
|
|
146
|
-
@filters.select(&:applied?)
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
@@ -1,207 +0,0 @@
|
|
|
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
|
-
module Coordinators
|
|
35
|
-
# Manager that keeps track of our offsets with the virtualization layer that are local
|
|
36
|
-
# to given partition assignment. It allows for easier offset management for virtual
|
|
37
|
-
# virtual partition cases as it provides us ability to mark as consumed and move the
|
|
38
|
-
# real offset behind as expected.
|
|
39
|
-
#
|
|
40
|
-
# @note We still use the regular coordinator "real" offset management as we want to have
|
|
41
|
-
# them as separated as possible because the real seek offset management is also used for
|
|
42
|
-
# pausing, filtering and others and should not be impacted by the virtual one
|
|
43
|
-
#
|
|
44
|
-
# @note This manager is **not** thread-safe by itself. It should operate from coordinator
|
|
45
|
-
# locked locations.
|
|
46
|
-
class VirtualOffsetManager
|
|
47
|
-
attr_reader :groups
|
|
48
|
-
|
|
49
|
-
# @param topic [String]
|
|
50
|
-
# @param partition [Integer]
|
|
51
|
-
# @param offset_metadata_strategy [Symbol] what metadata should we select. That is,
|
|
52
|
-
# should we use the most recent or one picked from the offset that is going to be
|
|
53
|
-
# committed
|
|
54
|
-
#
|
|
55
|
-
# @note We need topic and partition because we use a seek message (virtual) for real
|
|
56
|
-
# offset management. We could keep real message reference but this can be memory
|
|
57
|
-
# consuming and not worth it.
|
|
58
|
-
def initialize(topic, partition, offset_metadata_strategy)
|
|
59
|
-
@topic = topic
|
|
60
|
-
@partition = partition
|
|
61
|
-
@groups = []
|
|
62
|
-
@marked = {}
|
|
63
|
-
@offsets_metadata = {}
|
|
64
|
-
@real_offset = -1
|
|
65
|
-
@offset_metadata_strategy = offset_metadata_strategy
|
|
66
|
-
@current_offset_metadata = nil
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Clears the manager for a next collective operation
|
|
70
|
-
def clear
|
|
71
|
-
@groups.clear
|
|
72
|
-
@offsets_metadata.clear
|
|
73
|
-
@current_offset_metadata = nil
|
|
74
|
-
@marked.clear
|
|
75
|
-
@real_offset = -1
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# Registers an offset group coming from one virtual consumer. In order to move the real
|
|
79
|
-
# underlying offset accordingly, we need to make sure to track the virtual consumers
|
|
80
|
-
# offsets groups independently and only materialize the end result.
|
|
81
|
-
#
|
|
82
|
-
# @param offsets_group [Array<Integer>] offsets from one virtual consumer
|
|
83
|
-
def register(offsets_group)
|
|
84
|
-
@groups << offsets_group
|
|
85
|
-
|
|
86
|
-
offsets_group.each { |offset| @marked[offset] = false }
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# Marks given message as marked (virtually consumed).
|
|
90
|
-
# We mark given message offset and other earlier offsets from the same group as done
|
|
91
|
-
# and we can refresh our real offset representation based on that as it might have
|
|
92
|
-
# changed to a newer real offset.
|
|
93
|
-
# @param message [Karafka::Messages::Message] message coming from VP we want to mark
|
|
94
|
-
# @param offset_metadata [String, nil] offset metadata. `nil` if none
|
|
95
|
-
def mark(message, offset_metadata)
|
|
96
|
-
offset = message.offset
|
|
97
|
-
|
|
98
|
-
# Store metadata when we materialize the most stable offset
|
|
99
|
-
@offsets_metadata[offset] = offset_metadata
|
|
100
|
-
@current_offset_metadata = offset_metadata
|
|
101
|
-
|
|
102
|
-
group = nil
|
|
103
|
-
position = nil
|
|
104
|
-
|
|
105
|
-
@groups.each do |reg_group|
|
|
106
|
-
pos = reg_group.index(offset)
|
|
107
|
-
|
|
108
|
-
if pos
|
|
109
|
-
group = reg_group
|
|
110
|
-
position = pos
|
|
111
|
-
break
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# This case can happen when someone uses MoM and wants to mark message from a previous
|
|
116
|
-
# batch as consumed. We can add it, since the real offset refresh will point to it
|
|
117
|
-
unless group
|
|
118
|
-
group = [offset]
|
|
119
|
-
position = 0
|
|
120
|
-
@groups << group
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# Mark all previous messages from the same group also as virtually consumed
|
|
124
|
-
group[0..position].each do |markable_offset|
|
|
125
|
-
# Set previous messages metadata offset as the offset of higher one for overwrites
|
|
126
|
-
# unless a different metadata were set explicitely
|
|
127
|
-
@offsets_metadata[markable_offset] ||= offset_metadata
|
|
128
|
-
@marked[markable_offset] = true
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# Recompute the real offset representation
|
|
132
|
-
materialize_real_offset
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# Mark all from all groups including the `message`.
|
|
136
|
-
# Useful when operating in a collapsed state for marking
|
|
137
|
-
# @param message [Karafka::Messages::Message]
|
|
138
|
-
# @param offset_metadata [String, nil]
|
|
139
|
-
def mark_until(message, offset_metadata)
|
|
140
|
-
mark(message, offset_metadata)
|
|
141
|
-
|
|
142
|
-
@groups.each do |group|
|
|
143
|
-
group.each do |offset|
|
|
144
|
-
next if offset > message.offset
|
|
145
|
-
|
|
146
|
-
@offsets_metadata[offset] = offset_metadata
|
|
147
|
-
@marked[offset] = true
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
materialize_real_offset
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
# @return [Array<Integer>] Offsets of messages already marked as consumed virtually
|
|
155
|
-
def marked
|
|
156
|
-
@marked.select { |_, status| status }.map { |offset, _| offset }.sort
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# Is there a real offset we can mark as consumed
|
|
160
|
-
# @return [Boolean]
|
|
161
|
-
def markable?
|
|
162
|
-
!@real_offset.negative?
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
# @return [Array<Messages::Seek, String>] markable message for real offset marking and
|
|
166
|
-
# its associated metadata
|
|
167
|
-
def markable
|
|
168
|
-
raise Errors::InvalidRealOffsetUsageError unless markable?
|
|
169
|
-
|
|
170
|
-
offset_metadata = case @offset_metadata_strategy
|
|
171
|
-
when :exact
|
|
172
|
-
@offsets_metadata.fetch(@real_offset)
|
|
173
|
-
when :current
|
|
174
|
-
@current_offset_metadata
|
|
175
|
-
else
|
|
176
|
-
raise Errors::UnsupportedCaseError, @offset_metadata_strategy
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
[
|
|
180
|
-
Messages::Seek.new(
|
|
181
|
-
@topic,
|
|
182
|
-
@partition,
|
|
183
|
-
@real_offset
|
|
184
|
-
),
|
|
185
|
-
offset_metadata
|
|
186
|
-
]
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
private
|
|
190
|
-
|
|
191
|
-
# Recomputes the biggest possible real offset we can have.
|
|
192
|
-
# It picks the biggest offset that has uninterrupted stream of virtually marked as
|
|
193
|
-
# consumed because this will be the collective offset.
|
|
194
|
-
def materialize_real_offset
|
|
195
|
-
@marked.keys.sort.each do |offset|
|
|
196
|
-
break unless @marked[offset]
|
|
197
|
-
|
|
198
|
-
@real_offset = offset
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
@real_offset = (@marked.keys.min - 1) if @real_offset.negative?
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|