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,105 @@
|
|
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
|
+
# Applier for all filters we want to have. Whether related to limiting messages based
|
18
|
+
# on the payload or any other things.
|
19
|
+
#
|
20
|
+
# From the outside world perspective, this encapsulates all the filters.
|
21
|
+
# This means that this is the API we expose as a single filter, allowing us to control
|
22
|
+
# the filtering via many filters easily.
|
23
|
+
class FiltersApplier
|
24
|
+
# @return [Array] registered filters array. Useful if we want to inject internal context
|
25
|
+
# aware filters.
|
26
|
+
attr_reader :filters
|
27
|
+
|
28
|
+
# @param coordinator [Pro::Coordinator] pro coordinator
|
29
|
+
def initialize(coordinator)
|
30
|
+
# Builds filters out of their factories
|
31
|
+
# We build it that way (providing topic and partition) because there may be a case where
|
32
|
+
# someone wants to have a specific logic that is per topic or partition. Like for example
|
33
|
+
# a case where there is a cache bypassing revocations for topic partition.
|
34
|
+
#
|
35
|
+
# We provide full Karafka routing topic here and not the name only, in case the filter
|
36
|
+
# would be customized based on other topic settings (like VPs, etc)
|
37
|
+
#
|
38
|
+
# This setup allows for biggest flexibility also because topic object holds the reference
|
39
|
+
# to the subscription group and consumer group
|
40
|
+
@filters = coordinator.topic.filtering.factories.map do |factory|
|
41
|
+
factory.call(coordinator.topic, coordinator.partition)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param messages [Array<Karafka::Messages::Message>] array with messages from the
|
46
|
+
# partition
|
47
|
+
def apply!(messages)
|
48
|
+
return unless active?
|
49
|
+
|
50
|
+
@filters.each { |filter| filter.apply!(messages) }
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Boolean] did we filter out any messages during filtering run
|
54
|
+
def applied?
|
55
|
+
return false unless active?
|
56
|
+
|
57
|
+
!applied.empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Symbol] consumer post-filtering action that should be taken
|
61
|
+
def action
|
62
|
+
return :skip unless applied?
|
63
|
+
|
64
|
+
# The highest priority is on a potential backoff from any of the filters because it is
|
65
|
+
# the less risky (delay and continue later)
|
66
|
+
return :pause if applied.any? { |filter| filter.action == :pause }
|
67
|
+
|
68
|
+
# If none of the filters wanted to pause, we can check for any that would want to seek
|
69
|
+
# and if there is any, we can go with this strategy
|
70
|
+
return :seek if applied.any? { |filter| filter.action == :seek }
|
71
|
+
|
72
|
+
:skip
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [Integer] minimum timeout we need to pause. This is the minimum for all the
|
76
|
+
# filters to satisfy all of them.
|
77
|
+
def timeout
|
78
|
+
applied.map(&:timeout).compact.min || 0
|
79
|
+
end
|
80
|
+
|
81
|
+
# The first message we do need to get next time we poll. We use the minimum not to jump
|
82
|
+
# accidentally by over any.
|
83
|
+
# @return [Karafka::Messages::Message, nil] cursor message or nil if none
|
84
|
+
# @note Cursor message can also return the offset in the time format
|
85
|
+
def cursor
|
86
|
+
return nil unless active?
|
87
|
+
|
88
|
+
applied.map(&:cursor).compact.min_by(&:offset)
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
# @return [Boolean] is filtering active
|
94
|
+
def active?
|
95
|
+
!@filters.empty?
|
96
|
+
end
|
97
|
+
|
98
|
+
# @return [Array<Object>] filters that applied any sort of messages limiting
|
99
|
+
def applied
|
100
|
+
@filters.select(&:applied?)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,39 @@
|
|
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
|
+
# Pro components related to processing part of Karafka
|
17
|
+
module Processing
|
18
|
+
# Pro jobs
|
19
|
+
module Jobs
|
20
|
+
# The main job type in a non-blocking variant.
|
21
|
+
# This variant works "like" the regular consumption but does not block the queue.
|
22
|
+
#
|
23
|
+
# It can be useful when having long lasting jobs that would exceed `max.poll.interval`
|
24
|
+
# if would block.
|
25
|
+
#
|
26
|
+
# @note It needs to be working with a proper consumer that will handle the partition
|
27
|
+
# management. This layer of the framework knows nothing about Kafka messages consumption.
|
28
|
+
class ConsumeNonBlocking < ::Karafka::Processing::Jobs::Consume
|
29
|
+
# Makes this job non-blocking from the start
|
30
|
+
# @param args [Array] any arguments accepted by `::Karafka::Processing::Jobs::Consume`
|
31
|
+
def initialize(*args)
|
32
|
+
super
|
33
|
+
@non_blocking = true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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
|
+
# Pro components related to processing part of Karafka
|
17
|
+
module Processing
|
18
|
+
# Pro jobs
|
19
|
+
module Jobs
|
20
|
+
# The revoked job type in a non-blocking variant.
|
21
|
+
# This variant works "like" the regular revoked but does not block the queue.
|
22
|
+
#
|
23
|
+
# It can be useful when having long lasting jobs that would exceed `max.poll.interval`
|
24
|
+
# in scenarios where there are more jobs than threads, without this being async we
|
25
|
+
# would potentially stop polling
|
26
|
+
class RevokedNonBlocking < ::Karafka::Processing::Jobs::Revoked
|
27
|
+
# Makes this job non-blocking from the start
|
28
|
+
# @param args [Array] any arguments accepted by `::Karafka::Processing::Jobs::Revoked`
|
29
|
+
def initialize(*args)
|
30
|
+
super
|
31
|
+
@non_blocking = true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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 jobs builder that supports lrj
|
18
|
+
class JobsBuilder < ::Karafka::Processing::JobsBuilder
|
19
|
+
# @param executor [Karafka::Processing::Executor]
|
20
|
+
def idle(executor)
|
21
|
+
Karafka::Processing::Jobs::Idle.new(executor)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param executor [Karafka::Processing::Executor]
|
25
|
+
# @param messages [Karafka::Messages::Messages] messages batch to be consumed
|
26
|
+
# @return [Karafka::Processing::Jobs::Consume] blocking job
|
27
|
+
# @return [Karafka::Pro::Processing::Jobs::ConsumeNonBlocking] non blocking for lrj
|
28
|
+
def consume(executor, messages)
|
29
|
+
if executor.topic.long_running_job?
|
30
|
+
Jobs::ConsumeNonBlocking.new(executor, messages)
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @param executor [Karafka::Processing::Executor]
|
37
|
+
# @return [Karafka::Processing::Jobs::Revoked] revocation job for non LRJ
|
38
|
+
# @return [Karafka::Processing::Jobs::RevokedNonBlocking] revocation job that is
|
39
|
+
# non-blocking, so when revocation job is scheduled for LRJ it also will not block
|
40
|
+
def revoked(executor)
|
41
|
+
if executor.topic.long_running_job?
|
42
|
+
Jobs::RevokedNonBlocking.new(executor)
|
43
|
+
else
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,69 @@
|
|
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 partitioner that can distribute work based on the virtual partitioner settings
|
18
|
+
class Partitioner < ::Karafka::Processing::Partitioner
|
19
|
+
# @param topic [String] topic name
|
20
|
+
# @param messages [Array<Karafka::Messages::Message>] karafka messages
|
21
|
+
# @param coordinator [Karafka::Pro::Processing::Coordinator] processing coordinator that
|
22
|
+
# will be used with those messages
|
23
|
+
# @yieldparam [Integer] group id
|
24
|
+
# @yieldparam [Array<Karafka::Messages::Message>] karafka messages
|
25
|
+
def call(topic, messages, coordinator)
|
26
|
+
ktopic = @subscription_group.topics.find(topic)
|
27
|
+
|
28
|
+
# We only partition work if we have:
|
29
|
+
# - a virtual partitioner
|
30
|
+
# - more than one thread to process the data
|
31
|
+
# - collective is not collapsed via coordinator
|
32
|
+
#
|
33
|
+
# With one thread it is not worth partitioning the work as the work itself will be
|
34
|
+
# assigned to one thread (pointless work)
|
35
|
+
#
|
36
|
+
# We collapse the partitioning on errors because we "regain" full ordering on a batch
|
37
|
+
# that potentially contains the data that caused the error.
|
38
|
+
#
|
39
|
+
# This is great because it allows us to run things without the parallelization that adds
|
40
|
+
# a bit of uncertainty and allows us to use DLQ and safely skip messages if needed.
|
41
|
+
if ktopic.virtual_partitions? &&
|
42
|
+
ktopic.virtual_partitions.max_partitions > 1 &&
|
43
|
+
!coordinator.collapsed?
|
44
|
+
# We need to reduce it to the max concurrency, so the group_id is not a direct effect
|
45
|
+
# of the end user action. Otherwise the persistence layer for consumers would cache
|
46
|
+
# it forever and it would cause memory leaks
|
47
|
+
#
|
48
|
+
# This also needs to be consistent because the aggregation here needs to warrant, that
|
49
|
+
# the same partitioned message will always be assigned to the same virtual partition.
|
50
|
+
# Otherwise in case of a window aggregation with VP spanning across several polls, the
|
51
|
+
# data could not be complete.
|
52
|
+
groupings = messages.group_by do |msg|
|
53
|
+
key = ktopic.virtual_partitions.partitioner.call(msg).to_s.sum
|
54
|
+
|
55
|
+
key % ktopic.virtual_partitions.max_partitions
|
56
|
+
end
|
57
|
+
|
58
|
+
groupings.each do |key, messages_group|
|
59
|
+
yield(key, messages_group)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
# When no virtual partitioner, works as regular one
|
63
|
+
yield(0, messages)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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
|
+
# Optimizes scheduler that takes into consideration of execution time needed to process
|
18
|
+
# messages from given topics partitions. It uses the non-preemptive LJF algorithm
|
19
|
+
#
|
20
|
+
# This scheduler is designed to optimize execution times on jobs that perform IO operations
|
21
|
+
# as when taking IO into consideration, the can achieve optimized parallel processing.
|
22
|
+
#
|
23
|
+
# This scheduler can also work with virtual partitions.
|
24
|
+
#
|
25
|
+
# Aside from consumption jobs, other jobs do not run often, thus we can leave them with
|
26
|
+
# default FIFO scheduler from the default Karafka scheduler
|
27
|
+
class Scheduler < ::Karafka::Processing::Scheduler
|
28
|
+
# Schedules jobs in the LJF order for consumption
|
29
|
+
#
|
30
|
+
# @param queue [Karafka::Processing::JobsQueue] queue where we want to put the jobs
|
31
|
+
# @param jobs_array [Array<Karafka::Processing::Jobs::Base>] jobs we want to schedule
|
32
|
+
#
|
33
|
+
def schedule_consumption(queue, jobs_array)
|
34
|
+
perf_tracker = PerformanceTracker.instance
|
35
|
+
|
36
|
+
ordered = []
|
37
|
+
|
38
|
+
jobs_array.each do |job|
|
39
|
+
ordered << [
|
40
|
+
job,
|
41
|
+
processing_cost(perf_tracker, job)
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
ordered.sort_by!(&:last)
|
46
|
+
ordered.reverse!
|
47
|
+
ordered.map!(&:first)
|
48
|
+
|
49
|
+
ordered.each do |job|
|
50
|
+
queue << job
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# @param perf_tracker [PerformanceTracker]
|
57
|
+
# @param job [Karafka::Processing::Jobs::Base] job we will be processing
|
58
|
+
# @return [Numeric] estimated cost of processing this job
|
59
|
+
def processing_cost(perf_tracker, job)
|
60
|
+
if job.is_a?(::Karafka::Processing::Jobs::Consume)
|
61
|
+
messages = job.messages
|
62
|
+
message = messages.first
|
63
|
+
|
64
|
+
perf_tracker.processing_time_p95(message.topic, message.partition) * messages.size
|
65
|
+
else
|
66
|
+
# LJF will set first the most expensive, but we want to run the zero cost jobs
|
67
|
+
# related to the lifecycle always first. That is why we "emulate" that they
|
68
|
+
# the longest possible jobs that anyone can run
|
69
|
+
Float::INFINITY
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
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 Strategies
|
18
|
+
module Aj
|
19
|
+
# ActiveJob enabled
|
20
|
+
# DLQ enabled
|
21
|
+
# Filtering enabled
|
22
|
+
# Long-Running Job enabled
|
23
|
+
# Manual offset management enabled
|
24
|
+
module DlqFtrLrjMom
|
25
|
+
include Strategies::Aj::FtrMom
|
26
|
+
include Strategies::Aj::DlqMom
|
27
|
+
include Strategies::Aj::LrjMom
|
28
|
+
|
29
|
+
# Features for this strategy
|
30
|
+
FEATURES = %i[
|
31
|
+
active_job
|
32
|
+
dead_letter_queue
|
33
|
+
filtering
|
34
|
+
long_running_job
|
35
|
+
manual_offset_management
|
36
|
+
].freeze
|
37
|
+
|
38
|
+
# This strategy assumes we do not early break on shutdown as it has VP
|
39
|
+
def handle_after_consume
|
40
|
+
coordinator.on_finished do
|
41
|
+
if coordinator.success?
|
42
|
+
coordinator.pause_tracker.reset
|
43
|
+
|
44
|
+
if coordinator.filtered? && !revoked?
|
45
|
+
handle_post_filtering
|
46
|
+
elsif !revoked?
|
47
|
+
# no need to check for manual seek because AJ consumer is internal and
|
48
|
+
# fully controlled by us
|
49
|
+
seek(coordinator.seek_offset, false)
|
50
|
+
resume
|
51
|
+
else
|
52
|
+
resume
|
53
|
+
end
|
54
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
55
|
+
retry_after_pause
|
56
|
+
else
|
57
|
+
coordinator.pause_tracker.reset
|
58
|
+
skippable_message, = find_skippable_message
|
59
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
60
|
+
mark_as_consumed(skippable_message)
|
61
|
+
pause(coordinator.seek_offset, nil, false)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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 Strategies
|
18
|
+
module Aj
|
19
|
+
# ActiveJob enabled
|
20
|
+
# DLQ enabled
|
21
|
+
# Filtering enabled
|
22
|
+
# Long-Running Job enabled
|
23
|
+
# Manual offset management enabled
|
24
|
+
# Virtual Partitions enabled
|
25
|
+
module DlqFtrLrjMomVp
|
26
|
+
include Strategies::Aj::FtrMom
|
27
|
+
include Strategies::Aj::DlqMomVp
|
28
|
+
include Strategies::Aj::LrjMom
|
29
|
+
|
30
|
+
# Features for this strategy
|
31
|
+
FEATURES = %i[
|
32
|
+
active_job
|
33
|
+
dead_letter_queue
|
34
|
+
filtering
|
35
|
+
long_running_job
|
36
|
+
manual_offset_management
|
37
|
+
virtual_partitions
|
38
|
+
].freeze
|
39
|
+
|
40
|
+
# This strategy assumes we do not early break on shutdown as it has VP
|
41
|
+
def handle_after_consume
|
42
|
+
coordinator.on_finished do |last_group_message|
|
43
|
+
if coordinator.success?
|
44
|
+
coordinator.pause_tracker.reset
|
45
|
+
|
46
|
+
# Since we have VP here we do not commit intermediate offsets and need to commit
|
47
|
+
# them here. We do commit in collapsed mode but this is generalized.
|
48
|
+
mark_as_consumed(last_group_message) unless revoked?
|
49
|
+
|
50
|
+
if coordinator.filtered? && !revoked?
|
51
|
+
handle_post_filtering
|
52
|
+
elsif !revoked?
|
53
|
+
# no need to check for manual seek because AJ consumer is internal and
|
54
|
+
# fully controlled by us
|
55
|
+
seek(coordinator.seek_offset, false)
|
56
|
+
resume
|
57
|
+
else
|
58
|
+
resume
|
59
|
+
end
|
60
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
61
|
+
retry_after_pause
|
62
|
+
else
|
63
|
+
coordinator.pause_tracker.reset
|
64
|
+
skippable_message, = find_skippable_message
|
65
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
66
|
+
mark_as_consumed(skippable_message)
|
67
|
+
pause(coordinator.seek_offset, nil, false)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,72 @@
|
|
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 Strategies
|
18
|
+
module Aj
|
19
|
+
# - Aj
|
20
|
+
# - Dlq
|
21
|
+
# - Ftr
|
22
|
+
# - Mom
|
23
|
+
module DlqFtrMom
|
24
|
+
include Strategies::Dlq::FtrMom
|
25
|
+
|
26
|
+
# Features for this strategy
|
27
|
+
FEATURES = %i[
|
28
|
+
active_job
|
29
|
+
dead_letter_queue
|
30
|
+
filtering
|
31
|
+
manual_offset_management
|
32
|
+
].freeze
|
33
|
+
|
34
|
+
# We write our own custom handler for after consume here, because we mark as consumed
|
35
|
+
# per each job in the AJ consumer itself (for this strategy). This means, that for DLQ
|
36
|
+
# dispatch, we can mark this message as consumed as well.
|
37
|
+
def handle_after_consume
|
38
|
+
coordinator.on_finished do
|
39
|
+
return if revoked?
|
40
|
+
|
41
|
+
if coordinator.success?
|
42
|
+
coordinator.pause_tracker.reset
|
43
|
+
|
44
|
+
return if coordinator.manual_pause?
|
45
|
+
|
46
|
+
handle_post_filtering
|
47
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
48
|
+
retry_after_pause
|
49
|
+
# If we've reached number of retries that we could, we need to skip the first
|
50
|
+
# message that was not marked as consumed, pause and continue, while also moving
|
51
|
+
# this message to the dead topic.
|
52
|
+
#
|
53
|
+
# For a Mom setup, this means, that user has to manage the checkpointing by
|
54
|
+
# himself. If no checkpointing is ever done, we end up with an endless loop.
|
55
|
+
else
|
56
|
+
coordinator.pause_tracker.reset
|
57
|
+
skippable_message, = find_skippable_message
|
58
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
59
|
+
# We can commit the offset here because we know that we skip it "forever" and
|
60
|
+
# since AJ consumer commits the offset after each job, we also know that the
|
61
|
+
# previous job was successful
|
62
|
+
mark_as_consumed(skippable_message)
|
63
|
+
pause(coordinator.seek_offset, nil, false)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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 Strategies
|
18
|
+
module Aj
|
19
|
+
# - Aj
|
20
|
+
# - Dlq
|
21
|
+
# - Ftr
|
22
|
+
# - Mom
|
23
|
+
# - VP
|
24
|
+
module DlqFtrMomVp
|
25
|
+
include Strategies::Aj::DlqMomVp
|
26
|
+
include Strategies::Aj::DlqFtrMom
|
27
|
+
|
28
|
+
# Features for this strategy
|
29
|
+
FEATURES = %i[
|
30
|
+
active_job
|
31
|
+
dead_letter_queue
|
32
|
+
filtering
|
33
|
+
manual_offset_management
|
34
|
+
virtual_partitions
|
35
|
+
].freeze
|
36
|
+
|
37
|
+
# AJ VP does not early stop on shutdown, hence here we can mark as consumed at the
|
38
|
+
# end of all VPs
|
39
|
+
def handle_after_consume
|
40
|
+
coordinator.on_finished do |last_group_message|
|
41
|
+
return if revoked?
|
42
|
+
|
43
|
+
if coordinator.success?
|
44
|
+
coordinator.pause_tracker.reset
|
45
|
+
|
46
|
+
return if coordinator.manual_pause?
|
47
|
+
|
48
|
+
mark_as_consumed(last_group_message)
|
49
|
+
|
50
|
+
handle_post_filtering
|
51
|
+
elsif coordinator.pause_tracker.attempt <= topic.dead_letter_queue.max_retries
|
52
|
+
retry_after_pause
|
53
|
+
# If we've reached number of retries that we could, we need to skip the first
|
54
|
+
# message that was not marked as consumed, pause and continue, while also moving
|
55
|
+
# this message to the dead topic.
|
56
|
+
#
|
57
|
+
# For a Mom setup, this means, that user has to manage the checkpointing by
|
58
|
+
# himself. If no checkpointing is ever done, we end up with an endless loop.
|
59
|
+
else
|
60
|
+
coordinator.pause_tracker.reset
|
61
|
+
skippable_message, = find_skippable_message
|
62
|
+
dispatch_to_dlq(skippable_message) if dispatch_to_dlq?
|
63
|
+
# We can commit the offset here because we know that we skip it "forever" and
|
64
|
+
# since AJ consumer commits the offset after each job, we also know that the
|
65
|
+
# previous job was successful
|
66
|
+
mark_as_consumed(skippable_message)
|
67
|
+
pause(coordinator.seek_offset, nil, false)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|