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/cli/server.rb
CHANGED
@@ -2,69 +2,126 @@
|
|
2
2
|
|
3
3
|
module Karafka
|
4
4
|
# Karafka framework Cli
|
5
|
-
class Cli
|
5
|
+
class Cli
|
6
6
|
# Server Karafka Cli action
|
7
7
|
class Server < Base
|
8
|
-
|
9
|
-
CONTRACT = Contracts::ServerCliOptions.new.freeze
|
8
|
+
include Helpers::Colorize
|
10
9
|
|
11
|
-
|
10
|
+
# Types of things we can include / exclude from the routing via the CLI options
|
11
|
+
SUPPORTED_TYPES = ::Karafka::Routing::ActivityManager::SUPPORTED_TYPES
|
12
12
|
|
13
|
-
|
14
|
-
option aliases: 's'
|
15
|
-
option :daemon, default: false, type: :boolean, aliases: :d
|
16
|
-
option :pid, default: 'tmp/pids/karafka', type: :string, aliases: :p
|
17
|
-
option :consumer_groups, type: :array, default: nil, aliases: :g
|
13
|
+
private_constant :SUPPORTED_TYPES
|
18
14
|
|
19
|
-
|
20
|
-
def call
|
21
|
-
cli.info
|
15
|
+
desc 'Starts the Karafka server (short-cut alias: "s")'
|
22
16
|
|
23
|
-
|
17
|
+
aliases :s
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
option(
|
20
|
+
:consumer_groups,
|
21
|
+
'Runs server only with specified consumer groups',
|
22
|
+
Array,
|
23
|
+
%w[
|
24
|
+
-g
|
25
|
+
--consumer_groups
|
26
|
+
--include_consumer_groups
|
27
|
+
]
|
28
|
+
)
|
29
|
+
|
30
|
+
option(
|
31
|
+
:subscription_groups,
|
32
|
+
'Runs server only with specified subscription groups',
|
33
|
+
Array,
|
34
|
+
%w[
|
35
|
+
--subscription_groups
|
36
|
+
--include_subscription_groups
|
37
|
+
]
|
38
|
+
)
|
39
|
+
|
40
|
+
option(
|
41
|
+
:topics,
|
42
|
+
'Runs server only with specified topics',
|
43
|
+
Array,
|
44
|
+
%w[
|
45
|
+
--topics
|
46
|
+
--include_topics
|
47
|
+
]
|
48
|
+
)
|
49
|
+
|
50
|
+
option(
|
51
|
+
:exclude_consumer_groups,
|
52
|
+
'Runs server without specified consumer groups',
|
53
|
+
Array,
|
54
|
+
%w[
|
55
|
+
--exclude_consumer_groups
|
56
|
+
]
|
57
|
+
)
|
58
|
+
|
59
|
+
option(
|
60
|
+
:exclude_subscription_groups,
|
61
|
+
'Runs server without specified subscription groups',
|
62
|
+
Array,
|
63
|
+
%w[
|
64
|
+
--exclude_subscription_groups
|
65
|
+
]
|
66
|
+
)
|
67
|
+
|
68
|
+
option(
|
69
|
+
:exclude_topics,
|
70
|
+
'Runs server without specified topics',
|
71
|
+
Array,
|
72
|
+
%w[
|
73
|
+
--exclude_topics
|
74
|
+
]
|
75
|
+
)
|
76
|
+
|
77
|
+
# Start the Karafka server
|
78
|
+
def call
|
79
|
+
# Print our banner and info in the dev mode
|
80
|
+
print_marketing_info if Karafka::App.env.development?
|
29
81
|
|
30
|
-
|
31
|
-
|
32
|
-
Karafka::Server.consumer_groups = cli.options[:consumer_groups]
|
82
|
+
register_inclusions
|
83
|
+
register_exclusions
|
33
84
|
|
34
85
|
Karafka::Server.run
|
35
86
|
end
|
36
87
|
|
37
88
|
private
|
38
89
|
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
90
|
+
# Registers things we want to include (if defined)
|
91
|
+
def register_inclusions
|
92
|
+
activities = ::Karafka::App.config.internal.routing.activity_manager
|
93
|
+
|
94
|
+
SUPPORTED_TYPES.each do |type|
|
95
|
+
names = options[type] || []
|
44
96
|
|
45
|
-
|
97
|
+
names.each { |name| activities.include(type, name) }
|
98
|
+
end
|
46
99
|
end
|
47
100
|
|
48
|
-
#
|
49
|
-
def
|
50
|
-
::
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# We want to delay the moment in which the pidfile is removed as much as we can,
|
58
|
-
# so instead of removing it after the server stops running, we rely on the gc moment
|
59
|
-
# when this object gets removed (it is a bit later), so it is closer to the actual
|
60
|
-
# system process end. We do that, so monitoring and deployment tools that rely on a pid
|
61
|
-
# won't alarm or start new system process up until the current one is finished
|
62
|
-
ObjectSpace.define_finalizer(self, proc { send(:clean) })
|
101
|
+
# Registers things we want to exclude (if defined)
|
102
|
+
def register_exclusions
|
103
|
+
activities = ::Karafka::App.config.internal.routing.activity_manager
|
104
|
+
|
105
|
+
activities.class::SUPPORTED_TYPES.each do |type|
|
106
|
+
names = options[:"exclude_#{type}"] || []
|
107
|
+
|
108
|
+
names.each { |name| activities.exclude(type, name) }
|
109
|
+
end
|
63
110
|
end
|
64
111
|
|
65
|
-
#
|
66
|
-
def
|
67
|
-
|
112
|
+
# Prints marketing info
|
113
|
+
def print_marketing_info
|
114
|
+
Karafka.logger.info Info::BANNER
|
115
|
+
|
116
|
+
if Karafka.pro?
|
117
|
+
Karafka.logger.info(
|
118
|
+
green('Thank you for using Karafka Pro!')
|
119
|
+
)
|
120
|
+
else
|
121
|
+
Karafka.logger.info(
|
122
|
+
red('Upgrade to Karafka Pro for more features and support: https://karafka.io')
|
123
|
+
)
|
124
|
+
end
|
68
125
|
end
|
69
126
|
end
|
70
127
|
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
class Cli
|
5
|
+
# CLI actions related to Kafka cluster topics management
|
6
|
+
class Topics < Base
|
7
|
+
include Helpers::Colorize
|
8
|
+
|
9
|
+
desc 'Allows for the topics management (create, delete, reset, repartition)'
|
10
|
+
# @param action [String] action we want to take
|
11
|
+
def call(action = 'missing')
|
12
|
+
case action
|
13
|
+
when 'create'
|
14
|
+
create
|
15
|
+
when 'delete'
|
16
|
+
delete
|
17
|
+
when 'reset'
|
18
|
+
reset
|
19
|
+
when 'repartition'
|
20
|
+
repartition
|
21
|
+
when 'migrate'
|
22
|
+
migrate
|
23
|
+
else
|
24
|
+
raise ::ArgumentError, "Invalid topics action: #{action}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# Creates topics based on the routing setup and configuration
|
31
|
+
def create
|
32
|
+
declaratives_routing_topics.each do |topic|
|
33
|
+
name = topic.name
|
34
|
+
|
35
|
+
if existing_topics_names.include?(name)
|
36
|
+
puts "#{yellow('Skipping')} because topic #{name} already exists."
|
37
|
+
else
|
38
|
+
puts "Creating topic #{name}..."
|
39
|
+
Admin.create_topic(
|
40
|
+
name,
|
41
|
+
topic.declaratives.partitions,
|
42
|
+
topic.declaratives.replication_factor,
|
43
|
+
topic.declaratives.details
|
44
|
+
)
|
45
|
+
puts "#{green('Created')} topic #{name}."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Deletes routing based topics
|
51
|
+
def delete
|
52
|
+
declaratives_routing_topics.each do |topic|
|
53
|
+
name = topic.name
|
54
|
+
|
55
|
+
if existing_topics_names.include?(name)
|
56
|
+
puts "Deleting topic #{name}..."
|
57
|
+
Admin.delete_topic(name)
|
58
|
+
puts "#{green('Deleted')} topic #{name}."
|
59
|
+
else
|
60
|
+
puts "#{yellow('Skipping')} because topic #{name} does not exist."
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Deletes routing based topics and re-creates them
|
66
|
+
def reset
|
67
|
+
delete
|
68
|
+
|
69
|
+
# We need to invalidate the metadata cache, otherwise we will think, that the topic
|
70
|
+
# already exists
|
71
|
+
@existing_topics = nil
|
72
|
+
|
73
|
+
create
|
74
|
+
end
|
75
|
+
|
76
|
+
# Creates missing topics and aligns the partitions count
|
77
|
+
def migrate
|
78
|
+
create
|
79
|
+
|
80
|
+
@existing_topics = nil
|
81
|
+
|
82
|
+
repartition
|
83
|
+
end
|
84
|
+
|
85
|
+
# Increases number of partitions on topics that have less partitions than defined
|
86
|
+
# Will **not** create topics if missing.
|
87
|
+
def repartition
|
88
|
+
existing_partitions = existing_topics.map do |topic|
|
89
|
+
[topic.fetch(:topic_name), topic.fetch(:partition_count)]
|
90
|
+
end.to_h
|
91
|
+
|
92
|
+
declaratives_routing_topics.each do |topic|
|
93
|
+
name = topic.name
|
94
|
+
|
95
|
+
desired_count = topic.config.partitions
|
96
|
+
existing_count = existing_partitions.fetch(name, false)
|
97
|
+
|
98
|
+
if existing_count && existing_count < desired_count
|
99
|
+
puts "Increasing number of partitions to #{desired_count} on topic #{name}..."
|
100
|
+
Admin.create_partitions(name, desired_count)
|
101
|
+
change = desired_count - existing_count
|
102
|
+
puts "#{green('Created')} #{change} additional partitions on topic #{name}."
|
103
|
+
elsif existing_count
|
104
|
+
puts "#{yellow('Skipping')} because topic #{name} has #{existing_count} partitions."
|
105
|
+
else
|
106
|
+
puts "#{yellow('Skipping')} because topic #{name} does not exist."
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# @return [Array<Karafka::Routing::Topic>] all available topics that can be managed
|
112
|
+
# @note If topic is defined in multiple consumer groups, first config will be used. This
|
113
|
+
# means, that this CLI will not work for simultaneous management of multiple clusters from
|
114
|
+
# a single CLI command execution flow.
|
115
|
+
def declaratives_routing_topics
|
116
|
+
return @declaratives_routing_topics if @declaratives_routing_topics
|
117
|
+
|
118
|
+
collected_topics = {}
|
119
|
+
default_servers = Karafka::App.config.kafka[:'bootstrap.servers']
|
120
|
+
|
121
|
+
App.consumer_groups.each do |consumer_group|
|
122
|
+
consumer_group.topics.each do |topic|
|
123
|
+
# Skip topics that were explicitly disabled from management
|
124
|
+
next unless topic.declaratives.active?
|
125
|
+
# If bootstrap servers are different, consider this a different cluster
|
126
|
+
next unless default_servers == topic.kafka[:'bootstrap.servers']
|
127
|
+
|
128
|
+
collected_topics[topic.name] ||= topic
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
@declaratives_routing_topics = collected_topics.values
|
133
|
+
end
|
134
|
+
|
135
|
+
# @return [Array<Hash>] existing topics details
|
136
|
+
def existing_topics
|
137
|
+
@existing_topics ||= Admin.cluster_info.topics
|
138
|
+
end
|
139
|
+
|
140
|
+
# @return [Array<String>] names of already existing topics
|
141
|
+
def existing_topics_names
|
142
|
+
existing_topics.map { |topic| topic.fetch(:topic_name) }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
data/lib/karafka/cli.rb
CHANGED
@@ -2,47 +2,44 @@
|
|
2
2
|
|
3
3
|
module Karafka
|
4
4
|
# Karafka framework Cli
|
5
|
+
#
|
5
6
|
# If you want to add/modify command that belongs to CLI, please review all commands
|
6
7
|
# available in cli/ directory inside Karafka source code.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
class Cli
|
9
|
+
class << self
|
10
|
+
# Starts the CLI
|
11
|
+
def start
|
12
|
+
# Command we want to run, like install, server, etc
|
13
|
+
command_name = ARGV[0]
|
14
|
+
# Action for action-based commands like topics migrate
|
15
|
+
action = ARGV[1].to_s.start_with?('-') ? false : ARGV[1]
|
12
16
|
|
13
|
-
|
17
|
+
command = commands.find { |cmd| cmd.names.include?(command_name) }
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# have any Cli commands available
|
19
|
-
def prepare
|
20
|
-
cli_commands.each do |action|
|
21
|
-
action.bind_to(self)
|
22
|
-
end
|
23
|
-
end
|
19
|
+
if command
|
20
|
+
# Only actionable commands require command as an argument
|
21
|
+
args = action ? [action] : []
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
command.new.call(*args)
|
24
|
+
else
|
25
|
+
raise(
|
26
|
+
Karafka::Errors::UnrecognizedCommandError,
|
27
|
+
"Unrecognized command \"#{command_name}\""
|
28
|
+
)
|
29
|
+
end
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
32
33
|
|
33
|
-
# @return [Array<Class>]
|
34
|
-
def
|
35
|
-
|
36
|
-
.map! { |object| const_get(object) }
|
37
|
-
.keep_if do |object|
|
38
|
-
object.instance_of?(Class) && (object < Cli::Base)
|
39
|
-
end
|
34
|
+
# @return [Array<Class>] command classes
|
35
|
+
def commands
|
36
|
+
Base.commands
|
40
37
|
end
|
41
38
|
end
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
45
|
-
# This is kinda
|
42
|
+
# This is kinda tricky - since we don't have an autoload and other magic stuff
|
46
43
|
# like Rails does, so instead this method allows us to replace currently running
|
47
44
|
# console with a new one via Kernel.exec. It will start console with new code loaded
|
48
45
|
# Yes, we know that it is not turbo fast, however it is turbo convenient and small
|