Class: Karafka::Pro::Routing::Features::Multiplexing::Contracts::Routing

Inherits:
Contracts::Base
  • Object
show all
Defined in:
lib/karafka/pro/routing/features/multiplexing/contracts/routing.rb

Overview

Contract that validates that dynamic multiplexing is not used with statistics disabled. Dynamic multiplexing relies on statistics emitted events for scaling decisions and will not function properly without them.

Instance Method Summary collapse

Instance Method Details

#validate!(_builder, scope: []) ⇒ Object

Parameters:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/karafka/pro/routing/features/multiplexing/contracts/routing.rb', line 49

def validate!(_builder, scope: [])
  has_dynamic = Karafka::App
    .subscription_groups
    .values
    .flat_map(&:itself)
    .any? { |sg| sg.multiplexing? && sg.multiplexing.dynamic? }

  return unless has_dynamic

  stats_interval = App.config.kafka[:"statistics.interval.ms"]

  return unless stats_interval
  return unless stats_interval.zero?

  super(
    { dynamic_multiplexing_with_statistics_disabled: true },
    scope: scope
  )
end