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
data/lib/karafka/server.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module Karafka
|
4
4
|
# Karafka consuming server class
|
5
5
|
class Server
|
6
|
-
@consumer_threads = Concurrent::Array.new
|
7
|
-
|
8
6
|
# How long should we sleep between checks on shutting down consumers
|
9
7
|
SUPERVISION_SLEEP = 0.1
|
10
8
|
# What system exit code should we use when we terminated forcefully
|
@@ -17,69 +15,147 @@ module Karafka
|
|
17
15
|
|
18
16
|
class << self
|
19
17
|
# Set of consuming threads. Each consumer thread contains a single consumer
|
20
|
-
attr_accessor :
|
18
|
+
attr_accessor :listeners
|
19
|
+
|
20
|
+
# Set of workers
|
21
|
+
attr_accessor :workers
|
21
22
|
|
22
|
-
#
|
23
|
-
|
23
|
+
# Jobs queue
|
24
|
+
attr_accessor :jobs_queue
|
24
25
|
|
25
26
|
# Method which runs app
|
26
27
|
def run
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
28
|
+
self.listeners = []
|
29
|
+
self.workers = []
|
30
|
+
|
31
|
+
# We need to validate this prior to running because it may be executed also from the
|
32
|
+
# embedded
|
33
|
+
# We cannot validate this during the start because config needs to be populated and routes
|
34
|
+
# need to be defined.
|
35
|
+
config.internal.cli.contract.validate!(
|
36
|
+
config.internal.routing.activity_manager.to_h
|
37
|
+
)
|
38
|
+
|
39
|
+
process.on_sigint { stop }
|
40
|
+
process.on_sigquit { stop }
|
41
|
+
process.on_sigterm { stop }
|
42
|
+
process.on_sigtstp { quiet }
|
43
|
+
process.supervise
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
# Start is blocking until stop is called and when we stop, it will wait until
|
46
|
+
# all of the things are ready to stop
|
47
|
+
start
|
48
|
+
|
49
|
+
# We always need to wait for Karafka to stop here since we should wait for the stop running
|
50
|
+
# in a separate thread (or trap context) to indicate everything is closed
|
51
|
+
# Since `#start` is blocking, we will get here only after the runner is done. This will
|
52
|
+
# not add any performance degradation because of that.
|
53
|
+
sleep(0.1) until Karafka::App.terminated?
|
54
|
+
# Try its best to shutdown underlying components before re-raising
|
55
|
+
# rubocop:disable Lint/RescueException
|
56
|
+
rescue Exception => e
|
57
|
+
# rubocop:enable Lint/RescueException
|
58
|
+
stop
|
59
|
+
|
60
|
+
raise e
|
45
61
|
end
|
46
62
|
|
47
63
|
# Starts Karafka with a supervision
|
48
64
|
# @note We don't need to sleep because Karafka::Fetcher is locking and waiting to
|
49
65
|
# finish loop (and it won't happen until we explicitly want to stop)
|
50
|
-
def
|
51
|
-
process.supervise
|
66
|
+
def start
|
52
67
|
Karafka::App.run!
|
53
|
-
Karafka::
|
68
|
+
Karafka::Runner.new.call
|
54
69
|
end
|
55
70
|
|
56
71
|
# Stops Karafka with a supervision (as long as there is a shutdown timeout)
|
57
|
-
# If consumers won't stop in a given time frame, it will force them to exit
|
58
|
-
|
72
|
+
# If consumers or workers won't stop in a given time frame, it will force them to exit
|
73
|
+
#
|
74
|
+
# @note This method is not async. It should not be executed from the workers as it will
|
75
|
+
# lock them forever. If you need to run Karafka shutdown from within workers threads,
|
76
|
+
# please start a separate thread to do so.
|
77
|
+
def stop
|
78
|
+
# Initialize the stopping process only if Karafka was running
|
79
|
+
return if Karafka::App.stopping?
|
80
|
+
return if Karafka::App.stopped?
|
81
|
+
return if Karafka::App.terminated?
|
82
|
+
|
59
83
|
Karafka::App.stop!
|
60
84
|
|
61
|
-
|
62
|
-
timeout = Thread.new { Karafka::App.config.shutdown_timeout }.join.value
|
85
|
+
timeout = config.shutdown_timeout
|
63
86
|
|
64
87
|
# We check from time to time (for the timeout period) if all the threads finished
|
65
88
|
# their work and if so, we can just return and normal shutdown process will take place
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
return
|
70
|
-
end
|
89
|
+
# We divide it by 1000 because we use time in ms.
|
90
|
+
((timeout / 1_000) * SUPERVISION_CHECK_FACTOR).to_i.times do
|
91
|
+
return if listeners.count(&:alive?).zero? && workers.count(&:alive?).zero?
|
71
92
|
|
72
93
|
sleep SUPERVISION_SLEEP
|
73
94
|
end
|
74
95
|
|
75
96
|
raise Errors::ForcefulShutdownError
|
76
97
|
rescue Errors::ForcefulShutdownError => e
|
77
|
-
|
98
|
+
Karafka.monitor.instrument(
|
99
|
+
'error.occurred',
|
100
|
+
caller: self,
|
101
|
+
error: e,
|
102
|
+
type: 'app.stopping.error'
|
103
|
+
)
|
104
|
+
|
78
105
|
# We're done waiting, lets kill them!
|
79
|
-
|
106
|
+
workers.each(&:terminate)
|
107
|
+
listeners.each(&:terminate)
|
108
|
+
# We always need to shutdown clients to make sure we do not force the GC to close consumer.
|
109
|
+
# This can cause memory leaks and crashes.
|
110
|
+
listeners.each(&:shutdown)
|
111
|
+
|
112
|
+
# We also do not forcefully terminate everything when running in the embedded mode,
|
113
|
+
# otherwise we would overwrite the shutdown process of the process that started Karafka
|
114
|
+
return unless process.supervised?
|
80
115
|
|
81
116
|
# exit! is not within the instrumentation as it would not trigger due to exit
|
82
|
-
Kernel.exit!
|
117
|
+
Kernel.exit!(FORCEFUL_EXIT_CODE)
|
118
|
+
ensure
|
119
|
+
# We need to check if it wasn't an early exit to make sure that only on stop invocation
|
120
|
+
# can change the status after everything is closed
|
121
|
+
if timeout
|
122
|
+
Karafka::App.stopped!
|
123
|
+
|
124
|
+
# We close producer as the last thing as it can be used in the notification pipeline
|
125
|
+
# to dispatch state changes, etc
|
126
|
+
Karafka::App.producer.close
|
127
|
+
|
128
|
+
Karafka::App.terminate!
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Quiets the Karafka server.
|
133
|
+
#
|
134
|
+
# Karafka will stop processing but won't quit the consumer group, so no rebalance will be
|
135
|
+
# triggered until final shutdown.
|
136
|
+
def quiet
|
137
|
+
# We don't have to safe-guard it with check states as the state transitions work only
|
138
|
+
# in one direction
|
139
|
+
Karafka::App.quiet!
|
140
|
+
|
141
|
+
# We need one more thread to monitor the process and move to quieted once everything
|
142
|
+
# is quiet and no processing is happening anymore
|
143
|
+
Thread.new do
|
144
|
+
sleep(0.1) until listeners.coordinators.all?(&:finished?)
|
145
|
+
Karafka::App.quieted!
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
# @return [Karafka::Core::Configurable::Node] root config node
|
152
|
+
def config
|
153
|
+
Karafka::App.config
|
154
|
+
end
|
155
|
+
|
156
|
+
# @return [Karafka::Process] process wrapper instance used to catch system signal calls
|
157
|
+
def process
|
158
|
+
config.internal.process
|
83
159
|
end
|
84
160
|
end
|
85
161
|
end
|
@@ -0,0 +1,348 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
module Setup
|
5
|
+
# To simplify the overall design, in Karafka we define all the rdkafka settings in one scope
|
6
|
+
# under `kafka`. rdkafka though does not like when producer options are passed to the
|
7
|
+
# consumer configuration and issues warnings. This target map is used as a filtering layer, so
|
8
|
+
# only appropriate settings go to both producer and consumer
|
9
|
+
#
|
10
|
+
# It is built based on https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
|
11
|
+
module AttributesMap
|
12
|
+
# List of rdkafka consumer accepted attributes
|
13
|
+
CONSUMER = %i[
|
14
|
+
allow.auto.create.topics
|
15
|
+
api.version.fallback.ms
|
16
|
+
api.version.request
|
17
|
+
api.version.request.timeout.ms
|
18
|
+
auto.commit.enable
|
19
|
+
auto.commit.interval.ms
|
20
|
+
auto.offset.reset
|
21
|
+
background_event_cb
|
22
|
+
bootstrap.servers
|
23
|
+
broker.address.family
|
24
|
+
broker.address.ttl
|
25
|
+
broker.version.fallback
|
26
|
+
builtin.features
|
27
|
+
check.crcs
|
28
|
+
client.dns.lookup
|
29
|
+
client.id
|
30
|
+
client.rack
|
31
|
+
closesocket_cb
|
32
|
+
connect_cb
|
33
|
+
connections.max.idle.ms
|
34
|
+
consume.callback.max.messages
|
35
|
+
consume_cb
|
36
|
+
coordinator.query.interval.ms
|
37
|
+
debug
|
38
|
+
default_topic_conf
|
39
|
+
enable.auto.commit
|
40
|
+
enable.auto.offset.store
|
41
|
+
enable.partition.eof
|
42
|
+
enable.random.seed
|
43
|
+
enable.sasl.oauthbearer.unsecure.jwt
|
44
|
+
enable.ssl.certificate.verification
|
45
|
+
enabled_events
|
46
|
+
error_cb
|
47
|
+
fetch.error.backoff.ms
|
48
|
+
fetch.max.bytes
|
49
|
+
fetch.message.max.bytes
|
50
|
+
fetch.min.bytes
|
51
|
+
fetch.queue.backoff.ms
|
52
|
+
fetch.wait.max.ms
|
53
|
+
group.id
|
54
|
+
group.instance.id
|
55
|
+
group.protocol.type
|
56
|
+
heartbeat.interval.ms
|
57
|
+
interceptors
|
58
|
+
internal.termination.signal
|
59
|
+
isolation.level
|
60
|
+
log.connection.close
|
61
|
+
log.queue
|
62
|
+
log.thread.name
|
63
|
+
log_cb
|
64
|
+
log_level
|
65
|
+
max.in.flight
|
66
|
+
max.in.flight.requests.per.connection
|
67
|
+
max.partition.fetch.bytes
|
68
|
+
max.poll.interval.ms
|
69
|
+
message.copy.max.bytes
|
70
|
+
message.max.bytes
|
71
|
+
metadata.broker.list
|
72
|
+
metadata.max.age.ms
|
73
|
+
oauthbearer_token_refresh_cb
|
74
|
+
offset.store.method
|
75
|
+
offset.store.path
|
76
|
+
offset.store.sync.interval.ms
|
77
|
+
offset_commit_cb
|
78
|
+
opaque
|
79
|
+
open_cb
|
80
|
+
partition.assignment.strategy
|
81
|
+
plugin.library.paths
|
82
|
+
queued.max.messages.kbytes
|
83
|
+
queued.min.messages
|
84
|
+
rebalance_cb
|
85
|
+
receive.message.max.bytes
|
86
|
+
reconnect.backoff.jitter.ms
|
87
|
+
reconnect.backoff.max.ms
|
88
|
+
reconnect.backoff.ms
|
89
|
+
resolve_cb
|
90
|
+
sasl.kerberos.keytab
|
91
|
+
sasl.kerberos.kinit.cmd
|
92
|
+
sasl.kerberos.min.time.before.relogin
|
93
|
+
sasl.kerberos.principal
|
94
|
+
sasl.kerberos.service.name
|
95
|
+
sasl.mechanism
|
96
|
+
sasl.mechanisms
|
97
|
+
sasl.oauthbearer.client.id
|
98
|
+
sasl.oauthbearer.client.secret
|
99
|
+
sasl.oauthbearer.config
|
100
|
+
sasl.oauthbearer.extensions
|
101
|
+
sasl.oauthbearer.method
|
102
|
+
sasl.oauthbearer.scope
|
103
|
+
sasl.oauthbearer.token.endpoint.url
|
104
|
+
sasl.password
|
105
|
+
sasl.username
|
106
|
+
security.protocol
|
107
|
+
session.timeout.ms
|
108
|
+
socket.blocking.max.ms
|
109
|
+
socket.connection.setup.timeout.ms
|
110
|
+
socket.keepalive.enable
|
111
|
+
socket.max.fails
|
112
|
+
socket.nagle.disable
|
113
|
+
socket.receive.buffer.bytes
|
114
|
+
socket.send.buffer.bytes
|
115
|
+
socket.timeout.ms
|
116
|
+
socket_cb
|
117
|
+
ssl.ca.certificate.stores
|
118
|
+
ssl.ca.location
|
119
|
+
ssl.ca.pem
|
120
|
+
ssl.certificate.location
|
121
|
+
ssl.certificate.pem
|
122
|
+
ssl.certificate.verify_cb
|
123
|
+
ssl.cipher.suites
|
124
|
+
ssl.crl.location
|
125
|
+
ssl.curves.list
|
126
|
+
ssl.endpoint.identification.algorithm
|
127
|
+
ssl.engine.id
|
128
|
+
ssl.engine.location
|
129
|
+
ssl.key.location
|
130
|
+
ssl.key.password
|
131
|
+
ssl.key.pem
|
132
|
+
ssl.keystore.location
|
133
|
+
ssl.keystore.password
|
134
|
+
ssl.providers
|
135
|
+
ssl.sigalgs.list
|
136
|
+
ssl_ca
|
137
|
+
ssl_certificate
|
138
|
+
ssl_engine_callback_data
|
139
|
+
ssl_key
|
140
|
+
statistics.interval.ms
|
141
|
+
stats_cb
|
142
|
+
throttle_cb
|
143
|
+
topic.blacklist
|
144
|
+
topic.metadata.propagation.max.ms
|
145
|
+
topic.metadata.refresh.fast.cnt
|
146
|
+
topic.metadata.refresh.fast.interval.ms
|
147
|
+
topic.metadata.refresh.interval.ms
|
148
|
+
topic.metadata.refresh.sparse
|
149
|
+
].freeze
|
150
|
+
|
151
|
+
# List of rdkafka producer accepted attributes
|
152
|
+
PRODUCER = %i[
|
153
|
+
acks
|
154
|
+
api.version.fallback.ms
|
155
|
+
api.version.request
|
156
|
+
api.version.request.timeout.ms
|
157
|
+
background_event_cb
|
158
|
+
batch.num.messages
|
159
|
+
batch.size
|
160
|
+
bootstrap.servers
|
161
|
+
broker.address.family
|
162
|
+
broker.address.ttl
|
163
|
+
broker.version.fallback
|
164
|
+
builtin.features
|
165
|
+
client.dns.lookup
|
166
|
+
client.id
|
167
|
+
client.rack
|
168
|
+
closesocket_cb
|
169
|
+
compression.codec
|
170
|
+
compression.level
|
171
|
+
compression.type
|
172
|
+
connect_cb
|
173
|
+
connections.max.idle.ms
|
174
|
+
debug
|
175
|
+
default_topic_conf
|
176
|
+
delivery.report.only.error
|
177
|
+
delivery.timeout.ms
|
178
|
+
dr_cb
|
179
|
+
dr_msg_cb
|
180
|
+
enable.gapless.guarantee
|
181
|
+
enable.idempotence
|
182
|
+
enable.random.seed
|
183
|
+
enable.sasl.oauthbearer.unsecure.jwt
|
184
|
+
enable.ssl.certificate.verification
|
185
|
+
enabled_events
|
186
|
+
error_cb
|
187
|
+
interceptors
|
188
|
+
internal.termination.signal
|
189
|
+
linger.ms
|
190
|
+
log.connection.close
|
191
|
+
log.queue
|
192
|
+
log.thread.name
|
193
|
+
log_cb
|
194
|
+
log_level
|
195
|
+
max.in.flight
|
196
|
+
max.in.flight.requests.per.connection
|
197
|
+
message.copy.max.bytes
|
198
|
+
message.max.bytes
|
199
|
+
message.send.max.retries
|
200
|
+
message.timeout.ms
|
201
|
+
metadata.broker.list
|
202
|
+
metadata.max.age.ms
|
203
|
+
msg_order_cmp
|
204
|
+
oauthbearer_token_refresh_cb
|
205
|
+
opaque
|
206
|
+
open_cb
|
207
|
+
partitioner
|
208
|
+
partitioner_cb
|
209
|
+
plugin.library.paths
|
210
|
+
produce.offset.report
|
211
|
+
queue.buffering.backpressure.threshold
|
212
|
+
queue.buffering.max.kbytes
|
213
|
+
queue.buffering.max.messages
|
214
|
+
queue.buffering.max.ms
|
215
|
+
queuing.strategy
|
216
|
+
receive.message.max.bytes
|
217
|
+
reconnect.backoff.jitter.ms
|
218
|
+
reconnect.backoff.max.ms
|
219
|
+
reconnect.backoff.ms
|
220
|
+
request.required.acks
|
221
|
+
request.timeout.ms
|
222
|
+
resolve_cb
|
223
|
+
retries
|
224
|
+
retry.backoff.max.ms
|
225
|
+
retry.backoff.ms
|
226
|
+
sasl.kerberos.keytab
|
227
|
+
sasl.kerberos.kinit.cmd
|
228
|
+
sasl.kerberos.min.time.before.relogin
|
229
|
+
sasl.kerberos.principal
|
230
|
+
sasl.kerberos.service.name
|
231
|
+
sasl.mechanism
|
232
|
+
sasl.mechanisms
|
233
|
+
sasl.oauthbearer.client.id
|
234
|
+
sasl.oauthbearer.client.secret
|
235
|
+
sasl.oauthbearer.config
|
236
|
+
sasl.oauthbearer.extensions
|
237
|
+
sasl.oauthbearer.method
|
238
|
+
sasl.oauthbearer.scope
|
239
|
+
sasl.oauthbearer.token.endpoint.url
|
240
|
+
sasl.password
|
241
|
+
sasl.username
|
242
|
+
security.protocol
|
243
|
+
socket.blocking.max.ms
|
244
|
+
socket.connection.setup.timeout.ms
|
245
|
+
socket.keepalive.enable
|
246
|
+
socket.max.fails
|
247
|
+
socket.nagle.disable
|
248
|
+
socket.receive.buffer.bytes
|
249
|
+
socket.send.buffer.bytes
|
250
|
+
socket.timeout.ms
|
251
|
+
socket_cb
|
252
|
+
ssl.ca.certificate.stores
|
253
|
+
ssl.ca.location
|
254
|
+
ssl.ca.pem
|
255
|
+
ssl.certificate.location
|
256
|
+
ssl.certificate.pem
|
257
|
+
ssl.certificate.verify_cb
|
258
|
+
ssl.cipher.suites
|
259
|
+
ssl.crl.location
|
260
|
+
ssl.curves.list
|
261
|
+
ssl.endpoint.identification.algorithm
|
262
|
+
ssl.engine.id
|
263
|
+
ssl.engine.location
|
264
|
+
ssl.key.location
|
265
|
+
ssl.key.password
|
266
|
+
ssl.key.pem
|
267
|
+
ssl.keystore.location
|
268
|
+
ssl.keystore.password
|
269
|
+
ssl.providers
|
270
|
+
ssl.sigalgs.list
|
271
|
+
ssl_ca
|
272
|
+
ssl_certificate
|
273
|
+
ssl_engine_callback_data
|
274
|
+
ssl_key
|
275
|
+
statistics.interval.ms
|
276
|
+
stats_cb
|
277
|
+
sticky.partitioning.linger.ms
|
278
|
+
throttle_cb
|
279
|
+
topic.blacklist
|
280
|
+
topic.metadata.propagation.max.ms
|
281
|
+
topic.metadata.refresh.fast.cnt
|
282
|
+
topic.metadata.refresh.fast.interval.ms
|
283
|
+
topic.metadata.refresh.interval.ms
|
284
|
+
topic.metadata.refresh.sparse
|
285
|
+
transaction.timeout.ms
|
286
|
+
transactional.id
|
287
|
+
].freeze
|
288
|
+
|
289
|
+
# Location of the file with rdkafka settings list
|
290
|
+
SOURCE = 'https://raw.githubusercontent.com/edenhill/librdkafka/master/CONFIGURATION.md'
|
291
|
+
|
292
|
+
private_constant :SOURCE
|
293
|
+
|
294
|
+
class << self
|
295
|
+
# Filter the provided settings leaving only the once applicable to the consumer
|
296
|
+
# @param kafka_settings [Hash] all kafka settings
|
297
|
+
# @return [Hash] settings applicable to the consumer
|
298
|
+
def consumer(kafka_settings)
|
299
|
+
kafka_settings.slice(*CONSUMER)
|
300
|
+
end
|
301
|
+
|
302
|
+
# Filter the provided settings leaving only the once applicable to the producer
|
303
|
+
# @param kafka_settings [Hash] all kafka settings
|
304
|
+
# @return [Hash] settings applicable to the producer
|
305
|
+
def producer(kafka_settings)
|
306
|
+
kafka_settings.slice(*PRODUCER)
|
307
|
+
end
|
308
|
+
|
309
|
+
# @private
|
310
|
+
# @return [Hash<Symbol, Array<Symbol>>] hash with consumer and producer attributes list
|
311
|
+
# that is sorted.
|
312
|
+
# @note This method should not be used directly. It is only used to generate appropriate
|
313
|
+
# options list in case it would change
|
314
|
+
def generate
|
315
|
+
# Not used anywhere else, hence required here
|
316
|
+
require 'open-uri'
|
317
|
+
|
318
|
+
attributes = { consumer: Set.new, producer: Set.new }
|
319
|
+
|
320
|
+
::URI.parse(SOURCE).open.readlines.each do |line|
|
321
|
+
next unless line.include?('|')
|
322
|
+
|
323
|
+
attribute, attribute_type = line.split('|').map(&:strip)
|
324
|
+
|
325
|
+
case attribute_type
|
326
|
+
when 'C'
|
327
|
+
attributes[:consumer] << attribute
|
328
|
+
when 'P'
|
329
|
+
attributes[:producer] << attribute
|
330
|
+
when '*'
|
331
|
+
attributes[:consumer] << attribute
|
332
|
+
attributes[:producer] << attribute
|
333
|
+
else
|
334
|
+
next
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
# This can be removed when 0.13 librdkafka is released
|
339
|
+
attributes[:producer].delete_if { |val| val == 'allow.auto.create.topics' }
|
340
|
+
|
341
|
+
attributes.transform_values!(&:sort)
|
342
|
+
attributes.each_value { |vals| vals.map!(&:to_sym) }
|
343
|
+
attributes
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|