karafka 1.4.12 → 2.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +10 -9
- data/.github/workflows/ci.yml +169 -31
- data/.rspec +4 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +716 -607
- data/CONTRIBUTING.md +10 -19
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -92
- data/LICENSE +17 -0
- data/LICENSE-COMM +89 -0
- data/LICENSE-LGPL +165 -0
- data/README.md +48 -47
- data/bin/benchmarks +99 -0
- data/bin/create_token +22 -0
- data/bin/integrations +310 -0
- data/bin/karafka +5 -14
- data/bin/record_rss +50 -0
- data/bin/rspecs +6 -0
- data/bin/scenario +29 -0
- data/bin/stress_many +13 -0
- data/bin/stress_one +13 -0
- data/bin/verify_license_integrity +37 -0
- data/bin/wait_for_kafka +24 -0
- data/certs/cert_chain.pem +26 -0
- data/certs/karafka-pro.pem +11 -0
- data/config/locales/errors.yml +97 -0
- data/config/locales/pro_errors.yml +59 -0
- data/docker-compose.yml +19 -11
- data/karafka.gemspec +26 -22
- data/lib/active_job/karafka.rb +17 -0
- data/lib/active_job/queue_adapters/karafka_adapter.rb +32 -0
- data/lib/karafka/active_job/consumer.rb +49 -0
- data/lib/karafka/active_job/current_attributes/loading.rb +36 -0
- data/lib/karafka/active_job/current_attributes/persistence.rb +28 -0
- data/lib/karafka/active_job/current_attributes.rb +42 -0
- data/lib/karafka/active_job/dispatcher.rb +69 -0
- data/lib/karafka/active_job/job_extensions.rb +34 -0
- data/lib/karafka/active_job/job_options_contract.rb +32 -0
- data/lib/karafka/admin.rb +313 -0
- data/lib/karafka/app.rb +47 -23
- data/lib/karafka/base_consumer.rb +260 -29
- data/lib/karafka/cli/base.rb +67 -36
- data/lib/karafka/cli/console.rb +18 -12
- data/lib/karafka/cli/help.rb +24 -0
- data/lib/karafka/cli/info.rb +47 -12
- data/lib/karafka/cli/install.rb +23 -14
- data/lib/karafka/cli/server.rb +101 -44
- data/lib/karafka/cli/topics.rb +146 -0
- data/lib/karafka/cli.rb +24 -27
- data/lib/karafka/connection/client.rb +553 -90
- data/lib/karafka/connection/consumer_group_coordinator.rb +48 -0
- data/lib/karafka/connection/listener.rb +294 -38
- data/lib/karafka/connection/listeners_batch.rb +40 -0
- data/lib/karafka/connection/messages_buffer.rb +84 -0
- data/lib/karafka/connection/pauses_manager.rb +46 -0
- data/lib/karafka/connection/proxy.rb +98 -0
- data/lib/karafka/connection/raw_messages_buffer.rb +101 -0
- data/lib/karafka/connection/rebalance_manager.rb +105 -0
- data/lib/karafka/contracts/base.rb +17 -0
- data/lib/karafka/contracts/config.rb +130 -11
- data/lib/karafka/contracts/consumer_group.rb +32 -187
- data/lib/karafka/contracts/server_cli_options.rb +80 -19
- data/lib/karafka/contracts/topic.rb +65 -0
- data/lib/karafka/contracts.rb +1 -1
- data/lib/karafka/embedded.rb +36 -0
- data/lib/karafka/env.rb +46 -0
- data/lib/karafka/errors.rb +37 -21
- data/lib/karafka/helpers/async.rb +33 -0
- data/lib/karafka/helpers/colorize.rb +26 -0
- data/lib/karafka/helpers/multi_delegator.rb +2 -2
- data/lib/karafka/instrumentation/callbacks/error.rb +39 -0
- data/lib/karafka/instrumentation/callbacks/rebalance.rb +64 -0
- data/lib/karafka/instrumentation/callbacks/statistics.rb +51 -0
- data/lib/karafka/instrumentation/logger_listener.rb +303 -0
- data/lib/karafka/instrumentation/monitor.rb +13 -61
- data/lib/karafka/instrumentation/notifications.rb +79 -0
- data/lib/karafka/instrumentation/proctitle_listener.rb +7 -16
- data/lib/karafka/instrumentation/vendors/appsignal/base.rb +30 -0
- data/lib/karafka/instrumentation/vendors/appsignal/client.rb +122 -0
- data/lib/karafka/instrumentation/vendors/appsignal/dashboard.json +222 -0
- data/lib/karafka/instrumentation/vendors/appsignal/errors_listener.rb +30 -0
- data/lib/karafka/instrumentation/vendors/appsignal/metrics_listener.rb +331 -0
- data/lib/karafka/instrumentation/vendors/datadog/dashboard.json +1 -0
- data/lib/karafka/instrumentation/vendors/datadog/logger_listener.rb +155 -0
- data/lib/karafka/instrumentation/vendors/datadog/metrics_listener.rb +264 -0
- data/lib/karafka/instrumentation/vendors/kubernetes/liveness_listener.rb +176 -0
- data/lib/karafka/licenser.rb +78 -0
- data/lib/karafka/messages/batch_metadata.rb +52 -0
- data/lib/karafka/messages/builders/batch_metadata.rb +60 -0
- data/lib/karafka/messages/builders/message.rb +40 -0
- data/lib/karafka/messages/builders/messages.rb +36 -0
- data/lib/karafka/{params/params.rb → messages/message.rb} +20 -13
- data/lib/karafka/messages/messages.rb +71 -0
- data/lib/karafka/{params → messages}/metadata.rb +4 -6
- data/lib/karafka/messages/parser.rb +14 -0
- data/lib/karafka/messages/seek.rb +12 -0
- data/lib/karafka/patches/rdkafka/bindings.rb +122 -0
- data/lib/karafka/patches/rdkafka/opaque.rb +36 -0
- data/lib/karafka/pro/active_job/consumer.rb +47 -0
- data/lib/karafka/pro/active_job/dispatcher.rb +86 -0
- data/lib/karafka/pro/active_job/job_options_contract.rb +45 -0
- data/lib/karafka/pro/cleaner/errors.rb +27 -0
- data/lib/karafka/pro/cleaner/messages/message.rb +46 -0
- data/lib/karafka/pro/cleaner/messages/messages.rb +42 -0
- data/lib/karafka/pro/cleaner.rb +41 -0
- data/lib/karafka/pro/contracts/base.rb +23 -0
- data/lib/karafka/pro/contracts/server_cli_options.rb +111 -0
- data/lib/karafka/pro/encryption/cipher.rb +58 -0
- data/lib/karafka/pro/encryption/contracts/config.rb +79 -0
- data/lib/karafka/pro/encryption/errors.rb +27 -0
- data/lib/karafka/pro/encryption/messages/middleware.rb +46 -0
- data/lib/karafka/pro/encryption/messages/parser.rb +56 -0
- data/lib/karafka/pro/encryption/setup/config.rb +48 -0
- data/lib/karafka/pro/encryption.rb +47 -0
- data/lib/karafka/pro/iterator/expander.rb +95 -0
- data/lib/karafka/pro/iterator/tpl_builder.rb +155 -0
- data/lib/karafka/pro/iterator.rb +170 -0
- data/lib/karafka/pro/loader.rb +106 -0
- data/lib/karafka/pro/performance_tracker.rb +84 -0
- data/lib/karafka/pro/processing/collapser.rb +62 -0
- data/lib/karafka/pro/processing/coordinator.rb +147 -0
- data/lib/karafka/pro/processing/filters/base.rb +61 -0
- data/lib/karafka/pro/processing/filters/delayer.rb +70 -0
- data/lib/karafka/pro/processing/filters/expirer.rb +51 -0
- data/lib/karafka/pro/processing/filters/inline_insights_delayer.rb +78 -0
- data/lib/karafka/pro/processing/filters/throttler.rb +84 -0
- data/lib/karafka/pro/processing/filters/virtual_limiter.rb +52 -0
- data/lib/karafka/pro/processing/filters_applier.rb +105 -0
- data/lib/karafka/pro/processing/jobs/consume_non_blocking.rb +39 -0
- data/lib/karafka/pro/processing/jobs/revoked_non_blocking.rb +37 -0
- data/lib/karafka/pro/processing/jobs_builder.rb +50 -0
- data/lib/karafka/pro/processing/partitioner.rb +69 -0
- data/lib/karafka/pro/processing/scheduler.rb +75 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom.rb +70 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom_vp.rb +76 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom.rb +72 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom_vp.rb +76 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom.rb +66 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom_vp.rb +70 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_mom.rb +64 -0
- data/lib/karafka/pro/processing/strategies/aj/dlq_mom_vp.rb +69 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom.rb +38 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom_vp.rb +66 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_mom.rb +38 -0
- data/lib/karafka/pro/processing/strategies/aj/ftr_mom_vp.rb +58 -0
- data/lib/karafka/pro/processing/strategies/aj/lrj_mom.rb +37 -0
- data/lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb +82 -0
- data/lib/karafka/pro/processing/strategies/aj/mom.rb +36 -0
- data/lib/karafka/pro/processing/strategies/aj/mom_vp.rb +52 -0
- data/lib/karafka/pro/processing/strategies/base.rb +26 -0
- data/lib/karafka/pro/processing/strategies/default.rb +105 -0
- data/lib/karafka/pro/processing/strategies/dlq/default.rb +137 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr.rb +61 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj.rb +75 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom.rb +71 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom_vp.rb +43 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_vp.rb +41 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb +69 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_mom_vp.rb +41 -0
- data/lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj.rb +64 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb +65 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_mom_vp.rb +36 -0
- data/lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb +39 -0
- data/lib/karafka/pro/processing/strategies/dlq/mom.rb +68 -0
- data/lib/karafka/pro/processing/strategies/dlq/mom_vp.rb +37 -0
- data/lib/karafka/pro/processing/strategies/dlq/vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/ftr/default.rb +111 -0
- data/lib/karafka/pro/processing/strategies/ftr/vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/lrj/default.rb +85 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr.rb +69 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr_mom.rb +67 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr_mom_vp.rb +40 -0
- data/lib/karafka/pro/processing/strategies/lrj/ftr_vp.rb +39 -0
- data/lib/karafka/pro/processing/strategies/lrj/mom.rb +77 -0
- data/lib/karafka/pro/processing/strategies/lrj/mom_vp.rb +38 -0
- data/lib/karafka/pro/processing/strategies/lrj/vp.rb +36 -0
- data/lib/karafka/pro/processing/strategies/mom/default.rb +46 -0
- data/lib/karafka/pro/processing/strategies/mom/ftr.rb +53 -0
- data/lib/karafka/pro/processing/strategies/mom/ftr_vp.rb +37 -0
- data/lib/karafka/pro/processing/strategies/mom/vp.rb +35 -0
- data/lib/karafka/pro/processing/strategies/vp/default.rb +124 -0
- data/lib/karafka/pro/processing/strategies.rb +22 -0
- data/lib/karafka/pro/processing/strategy_selector.rb +84 -0
- data/lib/karafka/pro/processing/virtual_offset_manager.rb +147 -0
- data/lib/karafka/pro/routing/features/active_job/builder.rb +45 -0
- data/lib/karafka/pro/routing/features/active_job.rb +26 -0
- data/lib/karafka/pro/routing/features/base.rb +24 -0
- data/lib/karafka/pro/routing/features/dead_letter_queue/contracts/topic.rb +53 -0
- data/lib/karafka/pro/routing/features/dead_letter_queue.rb +27 -0
- data/lib/karafka/pro/routing/features/delaying/config.rb +27 -0
- data/lib/karafka/pro/routing/features/delaying/contracts/topic.rb +41 -0
- data/lib/karafka/pro/routing/features/delaying/topic.rb +59 -0
- data/lib/karafka/pro/routing/features/delaying.rb +29 -0
- data/lib/karafka/pro/routing/features/expiring/config.rb +27 -0
- data/lib/karafka/pro/routing/features/expiring/contracts/topic.rb +41 -0
- data/lib/karafka/pro/routing/features/expiring/topic.rb +59 -0
- data/lib/karafka/pro/routing/features/expiring.rb +27 -0
- data/lib/karafka/pro/routing/features/filtering/config.rb +40 -0
- data/lib/karafka/pro/routing/features/filtering/contracts/topic.rb +44 -0
- data/lib/karafka/pro/routing/features/filtering/topic.rb +51 -0
- data/lib/karafka/pro/routing/features/filtering.rb +27 -0
- data/lib/karafka/pro/routing/features/inline_insights/config.rb +32 -0
- data/lib/karafka/pro/routing/features/inline_insights/contracts/topic.rb +41 -0
- data/lib/karafka/pro/routing/features/inline_insights/topic.rb +52 -0
- data/lib/karafka/pro/routing/features/inline_insights.rb +26 -0
- data/lib/karafka/pro/routing/features/long_running_job/config.rb +28 -0
- data/lib/karafka/pro/routing/features/long_running_job/contracts/topic.rb +40 -0
- data/lib/karafka/pro/routing/features/long_running_job/topic.rb +42 -0
- data/lib/karafka/pro/routing/features/long_running_job.rb +28 -0
- data/lib/karafka/pro/routing/features/patterns/builder.rb +38 -0
- data/lib/karafka/pro/routing/features/patterns/config.rb +54 -0
- data/lib/karafka/pro/routing/features/patterns/consumer_group.rb +72 -0
- data/lib/karafka/pro/routing/features/patterns/contracts/consumer_group.rb +62 -0
- data/lib/karafka/pro/routing/features/patterns/contracts/pattern.rb +46 -0
- data/lib/karafka/pro/routing/features/patterns/contracts/topic.rb +41 -0
- data/lib/karafka/pro/routing/features/patterns/detector.rb +71 -0
- data/lib/karafka/pro/routing/features/patterns/pattern.rb +95 -0
- data/lib/karafka/pro/routing/features/patterns/patterns.rb +35 -0
- data/lib/karafka/pro/routing/features/patterns/topic.rb +50 -0
- data/lib/karafka/pro/routing/features/patterns/topics.rb +53 -0
- data/lib/karafka/pro/routing/features/patterns.rb +33 -0
- data/lib/karafka/pro/routing/features/pausing/contracts/topic.rb +51 -0
- data/lib/karafka/pro/routing/features/pausing/topic.rb +44 -0
- data/lib/karafka/pro/routing/features/pausing.rb +25 -0
- data/lib/karafka/pro/routing/features/throttling/config.rb +32 -0
- data/lib/karafka/pro/routing/features/throttling/contracts/topic.rb +44 -0
- data/lib/karafka/pro/routing/features/throttling/topic.rb +69 -0
- data/lib/karafka/pro/routing/features/throttling.rb +30 -0
- data/lib/karafka/pro/routing/features/virtual_partitions/config.rb +30 -0
- data/lib/karafka/pro/routing/features/virtual_partitions/contracts/topic.rb +55 -0
- data/lib/karafka/pro/routing/features/virtual_partitions/topic.rb +56 -0
- data/lib/karafka/pro/routing/features/virtual_partitions.rb +27 -0
- data/lib/karafka/pro.rb +13 -0
- data/lib/karafka/process.rb +24 -8
- data/lib/karafka/processing/coordinator.rb +181 -0
- data/lib/karafka/processing/coordinators_buffer.rb +62 -0
- data/lib/karafka/processing/executor.rb +155 -0
- data/lib/karafka/processing/executors_buffer.rb +72 -0
- data/lib/karafka/processing/expansions_selector.rb +22 -0
- data/lib/karafka/processing/inline_insights/consumer.rb +41 -0
- data/lib/karafka/processing/inline_insights/listener.rb +19 -0
- data/lib/karafka/processing/inline_insights/tracker.rb +128 -0
- data/lib/karafka/processing/jobs/base.rb +55 -0
- data/lib/karafka/processing/jobs/consume.rb +45 -0
- data/lib/karafka/processing/jobs/idle.rb +24 -0
- data/lib/karafka/processing/jobs/revoked.rb +22 -0
- data/lib/karafka/processing/jobs/shutdown.rb +23 -0
- data/lib/karafka/processing/jobs_builder.rb +28 -0
- data/lib/karafka/processing/jobs_queue.rb +150 -0
- data/lib/karafka/processing/partitioner.rb +24 -0
- data/lib/karafka/processing/result.rb +42 -0
- data/lib/karafka/processing/scheduler.rb +22 -0
- data/lib/karafka/processing/strategies/aj_dlq_mom.rb +44 -0
- data/lib/karafka/processing/strategies/aj_mom.rb +21 -0
- data/lib/karafka/processing/strategies/base.rb +52 -0
- data/lib/karafka/processing/strategies/default.rb +158 -0
- data/lib/karafka/processing/strategies/dlq.rb +88 -0
- data/lib/karafka/processing/strategies/dlq_mom.rb +49 -0
- data/lib/karafka/processing/strategies/mom.rb +29 -0
- data/lib/karafka/processing/strategy_selector.rb +47 -0
- data/lib/karafka/processing/worker.rb +93 -0
- data/lib/karafka/processing/workers_batch.rb +27 -0
- data/lib/karafka/railtie.rb +141 -0
- data/lib/karafka/routing/activity_manager.rb +84 -0
- data/lib/karafka/routing/builder.rb +45 -19
- data/lib/karafka/routing/consumer_group.rb +56 -20
- data/lib/karafka/routing/consumer_mapper.rb +1 -12
- data/lib/karafka/routing/features/active_job/builder.rb +33 -0
- data/lib/karafka/routing/features/active_job/config.rb +15 -0
- data/lib/karafka/routing/features/active_job/contracts/topic.rb +44 -0
- data/lib/karafka/routing/features/active_job/proxy.rb +14 -0
- data/lib/karafka/routing/features/active_job/topic.rb +33 -0
- data/lib/karafka/routing/features/active_job.rb +13 -0
- data/lib/karafka/routing/features/base/expander.rb +59 -0
- data/lib/karafka/routing/features/base.rb +71 -0
- data/lib/karafka/routing/features/dead_letter_queue/config.rb +19 -0
- data/lib/karafka/routing/features/dead_letter_queue/contracts/topic.rb +46 -0
- data/lib/karafka/routing/features/dead_letter_queue/topic.rb +41 -0
- data/lib/karafka/routing/features/dead_letter_queue.rb +16 -0
- data/lib/karafka/routing/features/declaratives/config.rb +18 -0
- data/lib/karafka/routing/features/declaratives/contracts/topic.rb +33 -0
- data/lib/karafka/routing/features/declaratives/topic.rb +44 -0
- data/lib/karafka/routing/features/declaratives.rb +14 -0
- data/lib/karafka/routing/features/inline_insights/config.rb +15 -0
- data/lib/karafka/routing/features/inline_insights/contracts/topic.rb +27 -0
- data/lib/karafka/routing/features/inline_insights/topic.rb +31 -0
- data/lib/karafka/routing/features/inline_insights.rb +40 -0
- data/lib/karafka/routing/features/manual_offset_management/config.rb +15 -0
- data/lib/karafka/routing/features/manual_offset_management/contracts/topic.rb +27 -0
- data/lib/karafka/routing/features/manual_offset_management/topic.rb +35 -0
- data/lib/karafka/routing/features/manual_offset_management.rb +18 -0
- data/lib/karafka/routing/proxy.rb +22 -21
- data/lib/karafka/routing/router.rb +24 -10
- data/lib/karafka/routing/subscription_group.rb +110 -0
- data/lib/karafka/routing/subscription_groups_builder.rb +65 -0
- data/lib/karafka/routing/topic.rb +87 -24
- data/lib/karafka/routing/topics.rb +46 -0
- data/lib/karafka/runner.rb +52 -0
- data/lib/karafka/serialization/json/deserializer.rb +7 -15
- data/lib/karafka/server.rb +113 -37
- data/lib/karafka/setup/attributes_map.rb +348 -0
- data/lib/karafka/setup/config.rb +256 -175
- data/lib/karafka/status.rb +54 -7
- data/lib/karafka/templates/example_consumer.rb.erb +16 -0
- data/lib/karafka/templates/karafka.rb.erb +33 -55
- data/lib/karafka/time_trackers/base.rb +14 -0
- data/lib/karafka/time_trackers/pause.rb +122 -0
- data/lib/karafka/time_trackers/poll.rb +69 -0
- data/lib/karafka/version.rb +1 -1
- data/lib/karafka.rb +91 -17
- data/renovate.json +9 -0
- data.tar.gz.sig +0 -0
- metadata +330 -168
- metadata.gz.sig +0 -0
- data/MIT-LICENCE +0 -18
- data/certs/mensfeld.pem +0 -25
- data/config/errors.yml +0 -41
- data/lib/karafka/assignment_strategies/round_robin.rb +0 -13
- data/lib/karafka/attributes_map.rb +0 -63
- data/lib/karafka/backends/inline.rb +0 -16
- data/lib/karafka/base_responder.rb +0 -226
- data/lib/karafka/cli/flow.rb +0 -48
- data/lib/karafka/cli/missingno.rb +0 -19
- data/lib/karafka/code_reloader.rb +0 -67
- data/lib/karafka/connection/api_adapter.rb +0 -158
- data/lib/karafka/connection/batch_delegator.rb +0 -55
- data/lib/karafka/connection/builder.rb +0 -23
- data/lib/karafka/connection/message_delegator.rb +0 -36
- data/lib/karafka/consumers/batch_metadata.rb +0 -10
- data/lib/karafka/consumers/callbacks.rb +0 -71
- data/lib/karafka/consumers/includer.rb +0 -64
- data/lib/karafka/consumers/responders.rb +0 -24
- data/lib/karafka/consumers/single_params.rb +0 -15
- data/lib/karafka/contracts/consumer_group_topic.rb +0 -19
- data/lib/karafka/contracts/responder_usage.rb +0 -54
- data/lib/karafka/fetcher.rb +0 -42
- data/lib/karafka/helpers/class_matcher.rb +0 -88
- data/lib/karafka/helpers/config_retriever.rb +0 -46
- data/lib/karafka/helpers/inflector.rb +0 -26
- data/lib/karafka/instrumentation/stdout_listener.rb +0 -140
- data/lib/karafka/params/batch_metadata.rb +0 -26
- data/lib/karafka/params/builders/batch_metadata.rb +0 -30
- data/lib/karafka/params/builders/params.rb +0 -38
- data/lib/karafka/params/builders/params_batch.rb +0 -25
- data/lib/karafka/params/params_batch.rb +0 -60
- data/lib/karafka/patches/ruby_kafka.rb +0 -47
- data/lib/karafka/persistence/client.rb +0 -29
- data/lib/karafka/persistence/consumers.rb +0 -45
- data/lib/karafka/persistence/topics.rb +0 -48
- data/lib/karafka/responders/builder.rb +0 -36
- data/lib/karafka/responders/topic.rb +0 -55
- data/lib/karafka/routing/topic_mapper.rb +0 -53
- data/lib/karafka/serialization/json/serializer.rb +0 -31
- data/lib/karafka/setup/configurators/water_drop.rb +0 -36
- data/lib/karafka/templates/application_responder.rb.erb +0 -11
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
# Manages the collapse of virtual partitions
|
18
|
+
# Since any non-virtual partition is actually a virtual partition of size one, we can use
|
19
|
+
# it in a generic manner without having to distinguish between those cases.
|
20
|
+
#
|
21
|
+
# We need to have notion of the offset until we want to collapse because upon pause and retry
|
22
|
+
# rdkafka may purge the buffer. This means, that we may end up with smaller or bigger
|
23
|
+
# (different) dataset and without tracking the end of collapse, there would be a chance for
|
24
|
+
# things to flicker. Tracking allows us to ensure, that collapse is happening until all the
|
25
|
+
# messages from the corrupted batch are processed.
|
26
|
+
class Collapser
|
27
|
+
# When initialized, nothing is collapsed
|
28
|
+
def initialize
|
29
|
+
@collapsed = false
|
30
|
+
@until_offset = -1
|
31
|
+
@mutex = Mutex.new
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Boolean] Should we collapse into a single consumer
|
35
|
+
def collapsed?
|
36
|
+
@collapsed
|
37
|
+
end
|
38
|
+
|
39
|
+
# Collapse until given offset. Until given offset is encountered or offset bigger than that
|
40
|
+
# we keep collapsing.
|
41
|
+
# @param offset [Integer] offset until which we keep the collapse
|
42
|
+
def collapse_until!(offset)
|
43
|
+
@mutex.synchronize do
|
44
|
+
# We check it here in case after a pause and re-fetch we would get less messages and
|
45
|
+
# one of them would cause an error. We do not want to overwrite the offset here unless
|
46
|
+
# it is bigger.
|
47
|
+
@until_offset = offset if offset > @until_offset
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sets the collapse state based on the first collective offset that we are going to process
|
52
|
+
# and makes the decision whether or not we need to still keep the collapse.
|
53
|
+
# @param first_offset [Integer] first offset from a collective batch
|
54
|
+
def refresh!(first_offset)
|
55
|
+
@mutex.synchronize do
|
56
|
+
@collapsed = first_offset < @until_offset
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
# Pro coordinator that provides extra orchestration methods useful for parallel processing
|
18
|
+
# within the same partition
|
19
|
+
class Coordinator < ::Karafka::Processing::Coordinator
|
20
|
+
extend Forwardable
|
21
|
+
|
22
|
+
def_delegators :@collapser, :collapsed?, :collapse_until!
|
23
|
+
|
24
|
+
attr_reader :filter, :virtual_offset_manager
|
25
|
+
|
26
|
+
# @param args [Object] anything the base coordinator accepts
|
27
|
+
def initialize(*args)
|
28
|
+
super
|
29
|
+
|
30
|
+
@executed = []
|
31
|
+
@flow_lock = Mutex.new
|
32
|
+
@collapser = Collapser.new
|
33
|
+
@filter = FiltersApplier.new(self)
|
34
|
+
|
35
|
+
return unless topic.virtual_partitions?
|
36
|
+
|
37
|
+
@virtual_offset_manager = VirtualOffsetManager.new(
|
38
|
+
topic.name,
|
39
|
+
partition
|
40
|
+
)
|
41
|
+
|
42
|
+
# We register our own "internal" filter to support filtering of messages that were marked
|
43
|
+
# as consumed virtually
|
44
|
+
@filter.filters << Filters::VirtualLimiter.new(
|
45
|
+
@virtual_offset_manager,
|
46
|
+
@collapser
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Starts the coordination process
|
51
|
+
# @param messages [Array<Karafka::Messages::Message>] messages for which processing we are
|
52
|
+
# going to coordinate.
|
53
|
+
def start(messages)
|
54
|
+
super
|
55
|
+
|
56
|
+
@collapser.refresh!(messages.first.offset)
|
57
|
+
|
58
|
+
@filter.apply!(messages)
|
59
|
+
|
60
|
+
@executed.clear
|
61
|
+
|
62
|
+
# We keep the old processed offsets until the collapsing is done and regular processing
|
63
|
+
# with virtualization is restored
|
64
|
+
@virtual_offset_manager.clear if topic.virtual_partitions? && !collapsed?
|
65
|
+
|
66
|
+
@last_message = messages.last
|
67
|
+
end
|
68
|
+
|
69
|
+
# Sets the consumer failure status and additionally starts the collapse until
|
70
|
+
#
|
71
|
+
# @param consumer [Karafka::BaseConsumer] consumer that failed
|
72
|
+
# @param error [StandardError] error from the failure
|
73
|
+
def failure!(consumer, error)
|
74
|
+
super
|
75
|
+
collapse_until!(@last_message.offset + 1)
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [Boolean] did any of the filters apply any logic that would cause use to run
|
79
|
+
# the filtering flow
|
80
|
+
def filtered?
|
81
|
+
@filter.applied?
|
82
|
+
end
|
83
|
+
|
84
|
+
# @return [Boolean] is the coordinated work finished or not
|
85
|
+
def finished?
|
86
|
+
@running_jobs.zero?
|
87
|
+
end
|
88
|
+
|
89
|
+
# Runs synchronized code once for a collective of virtual partitions prior to work being
|
90
|
+
# enqueued
|
91
|
+
def on_enqueued
|
92
|
+
@flow_lock.synchronize do
|
93
|
+
return unless executable?(:on_enqueued)
|
94
|
+
|
95
|
+
yield(@last_message)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Runs given code only once per all the coordinated jobs upon starting first of them
|
100
|
+
def on_started
|
101
|
+
@flow_lock.synchronize do
|
102
|
+
return unless executable?(:on_started)
|
103
|
+
|
104
|
+
yield(@last_message)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Runs once when all the work that is suppose to be coordinated is finished
|
109
|
+
# It runs once per all the coordinated jobs and should be used to run any type of post
|
110
|
+
# jobs coordination processing execution
|
111
|
+
def on_finished
|
112
|
+
@flow_lock.synchronize do
|
113
|
+
return unless finished?
|
114
|
+
return unless executable?(:on_finished)
|
115
|
+
|
116
|
+
yield(@last_message)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Runs once after a partition is revoked
|
121
|
+
def on_revoked
|
122
|
+
@flow_lock.synchronize do
|
123
|
+
return unless executable?(:on_revoked)
|
124
|
+
|
125
|
+
yield(@last_message)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
# Checks if given action is executable once. If it is and true is returned, this method
|
132
|
+
# will return false next time it is used.
|
133
|
+
#
|
134
|
+
# @param action [Symbol] what action we want to perform
|
135
|
+
# @return [Boolean] true if we can
|
136
|
+
# @note This method needs to run behind a mutex.
|
137
|
+
def executable?(action)
|
138
|
+
return false if @executed.include?(action)
|
139
|
+
|
140
|
+
@executed << action
|
141
|
+
|
142
|
+
true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
module Filters
|
18
|
+
# Base for all the filters.
|
19
|
+
# All filters (including custom) need to use this API.
|
20
|
+
#
|
21
|
+
# Due to the fact, that filters can limit data in such a way, that we need to pause or
|
22
|
+
# seek (throttling for example), the api is not just "remove some things from batch" but
|
23
|
+
# also provides ways to control the post-filtering operations that may be needed.
|
24
|
+
class Base
|
25
|
+
# @return [Karafka::Messages::Message, nil] the message that we want to use as a cursor
|
26
|
+
# one to pause or seek or nil if not applicable.
|
27
|
+
attr_reader :cursor
|
28
|
+
|
29
|
+
include Karafka::Core::Helpers::Time
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@applied = false
|
33
|
+
@cursor = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
# @param messages [Array<Karafka::Messages::Message>] array with messages. Please keep
|
37
|
+
# in mind, this may already be partial due to execution of previous filters.
|
38
|
+
def apply!(messages)
|
39
|
+
raise NotImplementedError, 'Implement in a subclass'
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Symbol] filter post-execution action on consumer. Either `:skip`, `:pause` or
|
43
|
+
# `:seek`.
|
44
|
+
def action
|
45
|
+
:skip
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Boolean] did this filter change messages in any way
|
49
|
+
def applied?
|
50
|
+
@applied
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Integer] default timeout for pausing (if applicable)
|
54
|
+
def timeout
|
55
|
+
0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
module Filters
|
18
|
+
# A filter that allows us to delay processing by pausing until time is right.
|
19
|
+
class Delayer < Base
|
20
|
+
# @param delay [Integer] ms delay / minimum age of each message we want to process
|
21
|
+
def initialize(delay)
|
22
|
+
super()
|
23
|
+
|
24
|
+
@delay = delay
|
25
|
+
end
|
26
|
+
|
27
|
+
# Removes too young messages
|
28
|
+
#
|
29
|
+
# @param messages [Array<Karafka::Messages::Message>]
|
30
|
+
def apply!(messages)
|
31
|
+
@applied = false
|
32
|
+
@cursor = nil
|
33
|
+
|
34
|
+
# Time on message is in seconds with ms precision, so we need to convert the ttl that
|
35
|
+
# is in ms to this format
|
36
|
+
border = ::Time.now.utc - @delay / 1_000.to_f
|
37
|
+
|
38
|
+
messages.delete_if do |message|
|
39
|
+
too_young = message.timestamp > border
|
40
|
+
|
41
|
+
if too_young
|
42
|
+
@applied = true
|
43
|
+
|
44
|
+
@cursor ||= message
|
45
|
+
end
|
46
|
+
|
47
|
+
@applied
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [Integer] timeout delay in ms
|
52
|
+
def timeout
|
53
|
+
return 0 unless @cursor
|
54
|
+
|
55
|
+
timeout = (@delay / 1_000.to_f) - (::Time.now.utc - @cursor.timestamp)
|
56
|
+
|
57
|
+
timeout <= 0 ? 0 : timeout * 1_000
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Symbol] action to take on post-filtering
|
61
|
+
def action
|
62
|
+
return :skip unless applied?
|
63
|
+
|
64
|
+
timeout <= 0 ? :seek : :pause
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
module Filters
|
18
|
+
# Expirer for removing too old messages.
|
19
|
+
# It never moves offsets in any way and does not impact the processing flow. It always
|
20
|
+
# runs `:skip` action.
|
21
|
+
class Expirer < Base
|
22
|
+
# @param ttl [Integer] maximum age of a message (in ms)
|
23
|
+
def initialize(ttl)
|
24
|
+
super()
|
25
|
+
|
26
|
+
@ttl = ttl
|
27
|
+
end
|
28
|
+
|
29
|
+
# Removes too old messages
|
30
|
+
#
|
31
|
+
# @param messages [Array<Karafka::Messages::Message>]
|
32
|
+
def apply!(messages)
|
33
|
+
@applied = false
|
34
|
+
|
35
|
+
# Time on message is in seconds with ms precision, so we need to convert the ttl that
|
36
|
+
# is in ms to this format
|
37
|
+
border = ::Time.now.utc - @ttl / 1_000.to_f
|
38
|
+
|
39
|
+
messages.delete_if do |message|
|
40
|
+
too_old = message.timestamp < border
|
41
|
+
|
42
|
+
@applied = true if too_old
|
43
|
+
|
44
|
+
too_old
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
module Filters
|
18
|
+
# Delayer that checks if we have appropriate insights available. If not, pauses for
|
19
|
+
# 5 seconds so the insights can be loaded from the broker.
|
20
|
+
#
|
21
|
+
# In case it would take more than five seconds to load insights, it will just pause again
|
22
|
+
#
|
23
|
+
# This filter ensures, that we always have inline insights that a consumer can use
|
24
|
+
#
|
25
|
+
# It is relevant in most cases only during the process start, when first poll may not
|
26
|
+
# yield statistics yet but will give some data.
|
27
|
+
class InlineInsightsDelayer < Base
|
28
|
+
# Minimum how long should we pause when there are no metrics
|
29
|
+
PAUSE_TIMEOUT = 5_000
|
30
|
+
|
31
|
+
private_constant :PAUSE_TIMEOUT
|
32
|
+
|
33
|
+
# @param topic [Karafka::Routing::Topic]
|
34
|
+
# @param partition [Integer] partition
|
35
|
+
def initialize(topic, partition)
|
36
|
+
super()
|
37
|
+
@topic = topic
|
38
|
+
@partition = partition
|
39
|
+
end
|
40
|
+
|
41
|
+
# Pauses if inline insights would not be available. Does nothing otherwise
|
42
|
+
#
|
43
|
+
# @param messages [Array<Karafka::Messages::Message>]
|
44
|
+
def apply!(messages)
|
45
|
+
@applied = false
|
46
|
+
@cursor = messages.first
|
47
|
+
|
48
|
+
# Nothing to do if there were no messages
|
49
|
+
# This can happen when we chain filters
|
50
|
+
return unless @cursor
|
51
|
+
|
52
|
+
insights = ::Karafka::Processing::InlineInsights::Tracker.find(
|
53
|
+
@topic,
|
54
|
+
@partition
|
55
|
+
)
|
56
|
+
|
57
|
+
# If insights are available, also nothing to do here and we can just process
|
58
|
+
return unless insights.empty?
|
59
|
+
|
60
|
+
messages.clear
|
61
|
+
|
62
|
+
@applied = true
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Integer] ms timeout in case of pause
|
66
|
+
def timeout
|
67
|
+
@cursor && applied? ? PAUSE_TIMEOUT : 0
|
68
|
+
end
|
69
|
+
|
70
|
+
# Pause when we had to back-off or skip if delay is not needed
|
71
|
+
def action
|
72
|
+
applied? ? :pause : :skip
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
# Namespace containing Pro out of the box filters used by various strategies
|
18
|
+
module Filters
|
19
|
+
# Throttler used to limit number of messages we can process in a given time interval
|
20
|
+
# The tricky thing is, that even if we throttle on 100 messages, if we've reached 100, we
|
21
|
+
# still need to indicate, that we throttle despite not receiving 101. Otherwise we will
|
22
|
+
# not pause the partition and will fetch more data that we should not process.
|
23
|
+
#
|
24
|
+
# This is a special type of a filter that always throttles and makes us wait / seek if
|
25
|
+
# anything is applied out.
|
26
|
+
class Throttler < Base
|
27
|
+
# @param limit [Integer] how many messages we can process in a given time
|
28
|
+
# @param interval [Integer] interval in milliseconds for which we want to process
|
29
|
+
def initialize(limit, interval)
|
30
|
+
super()
|
31
|
+
|
32
|
+
@limit = limit
|
33
|
+
@interval = interval
|
34
|
+
@requests = Hash.new { |h, k| h[k] = 0 }
|
35
|
+
end
|
36
|
+
|
37
|
+
# Limits number of messages to a range that we can process (if needed) and keeps track
|
38
|
+
# of how many messages we've processed in a given time
|
39
|
+
# @param messages [Array<Karafka::Messages::Message>] limits the number of messages to
|
40
|
+
# number we can accept in the context of throttling constraints
|
41
|
+
def apply!(messages)
|
42
|
+
@applied = false
|
43
|
+
@cursor = nil
|
44
|
+
@time = monotonic_now
|
45
|
+
@requests.delete_if { |timestamp, _| timestamp < (@time - @interval) }
|
46
|
+
values = @requests.values.sum
|
47
|
+
accepted = 0
|
48
|
+
|
49
|
+
messages.delete_if do |message|
|
50
|
+
# +1 because of current
|
51
|
+
@applied = (values + accepted + 1) > @limit
|
52
|
+
|
53
|
+
@cursor = message if @applied && @cursor.nil?
|
54
|
+
|
55
|
+
next true if @applied
|
56
|
+
|
57
|
+
accepted += 1
|
58
|
+
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
62
|
+
@requests[@time] += accepted
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Symbol] action to take upon throttler reaching certain state
|
66
|
+
def action
|
67
|
+
if applied?
|
68
|
+
timeout.zero? ? :seek : :pause
|
69
|
+
else
|
70
|
+
:skip
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# @return [Integer] minimum number of milliseconds to wait before getting more messages
|
75
|
+
# so we are no longer throttled and so we can process at least one message
|
76
|
+
def timeout
|
77
|
+
timeout = @interval - (monotonic_now - @time)
|
78
|
+
timeout <= 0 ? 0 : timeout
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This Karafka component is a Pro component under a commercial license.
|
4
|
+
# This Karafka component is NOT licensed under LGPL.
|
5
|
+
#
|
6
|
+
# All of the commercial components are present in the lib/karafka/pro directory of this
|
7
|
+
# repository and their usage requires commercial license agreement.
|
8
|
+
#
|
9
|
+
# Karafka has also commercial-friendly license, commercial support and commercial components.
|
10
|
+
#
|
11
|
+
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
|
12
|
+
# your code to Maciej Mensfeld.
|
13
|
+
|
14
|
+
module Karafka
|
15
|
+
module Pro
|
16
|
+
module Processing
|
17
|
+
module Filters
|
18
|
+
# Removes messages that are already marked as consumed in the virtual offset manager
|
19
|
+
# This should operate only when using virtual partitions.
|
20
|
+
#
|
21
|
+
# This cleaner prevents us from duplicated processing of messages that were virtually
|
22
|
+
# marked as consumed even if we could not mark them as consumed in Kafka. This allows us
|
23
|
+
# to limit reprocessing when errors occur drastically when operating with virtual
|
24
|
+
# partitions
|
25
|
+
#
|
26
|
+
# @note It should be registered only when VPs are used
|
27
|
+
class VirtualLimiter < Base
|
28
|
+
# @param manager [Processing::VirtualOffsetManager]
|
29
|
+
# @param collapser [Processing::Collapser]
|
30
|
+
def initialize(manager, collapser)
|
31
|
+
@manager = manager
|
32
|
+
@collapser = collapser
|
33
|
+
|
34
|
+
super()
|
35
|
+
end
|
36
|
+
|
37
|
+
# Remove messages that we already marked as virtually consumed. Does nothing if not in
|
38
|
+
# the collapsed mode.
|
39
|
+
#
|
40
|
+
# @param messages [Array<Karafka::Messages::Message>]
|
41
|
+
def apply!(messages)
|
42
|
+
return unless @collapser.collapsed?
|
43
|
+
|
44
|
+
marked = @manager.marked
|
45
|
+
|
46
|
+
messages.delete_if { |message| marked.include?(message.offset) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|