Class: Karafka::Routing::Features::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/routing/features/base.rb,
lib/karafka/routing/features/base/expander.rb

Overview

Base for all the features

Defined Under Namespace

Classes: Expander

Class Method Summary collapse

Class Method Details

.activateObject

Extends topic and builder with given feature API



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/karafka/routing/features/base.rb', line 15

def activate
  if const_defined?('Topic', false)
    Topic.prepend(self::Topic)
  end

  if const_defined?('Topics', false)
    Topics.prepend(self::Topics)
  end

  if const_defined?('ConsumerGroup', false)
    ConsumerGroup.prepend(self::ConsumerGroup)
  end

  if const_defined?('Proxy', false)
    Proxy.prepend(self::Proxy)
  end

  if const_defined?('Builder', false)
    Builder.prepend(self::Builder)
  end

  if const_defined?('Contracts', false)
    Builder.prepend(Base::Expander.new(self))
  end

  if const_defined?('SubscriptionGroup', false)
    SubscriptionGroup.prepend(self::SubscriptionGroup)
  end

  if const_defined?('SubscriptionGroupsBuilder', false)
    SubscriptionGroupsBuilder.prepend(self::SubscriptionGroupsBuilder)
  end
end

.load_allObject

Loads all the features and activates them once



50
51
52
53
54
55
56
# File 'lib/karafka/routing/features/base.rb', line 50

def load_all
  return if @loaded

  features.each(&:activate)

  @loaded = true
end

.post_setup_all(config) ⇒ Object

Runs post setup routing features configuration operations

Parameters:

  • config (Karafka::Core::Configurable::Node)


67
68
69
# File 'lib/karafka/routing/features/base.rb', line 67

def post_setup_all(config)
  features.each { |feature| feature.post_setup(config) }
end

.pre_setup_all(config) ⇒ Object

Parameters:

  • config (Karafka::Core::Configurable::Node)

    app config that we can alter with particular routing feature specific stuff if needed



60
61
62
# File 'lib/karafka/routing/features/base.rb', line 60

def pre_setup_all(config)
  features.each { |feature| feature.pre_setup(config) }
end