Class: Karafka::Cli::Server

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/cli/server.rb

Overview

Server Karafka Cli action

Constant Summary collapse

OPTIONS_BUILDER =

Those options can also be used when in swarm mode, hence we re-use

lambda do
  option(
    :consumer_groups,
    'Runs server only with specified consumer groups',
    Array,
    %w[
      -g
      --consumer_groups
      --include_consumer_groups
    ]
  )

  option(
    :subscription_groups,
    'Runs server only with specified subscription groups',
    Array,
    %w[
      --subscription_groups
      --include_subscription_groups
    ]
  )

  option(
    :topics,
    'Runs server only with specified topics',
    Array,
    %w[
      --topics
      --include_topics
    ]
  )

  option(
    :exclude_consumer_groups,
    'Runs server without specified consumer groups',
    Array,
    %w[
      --exclude_consumer_groups
    ]
  )

  option(
    :exclude_subscription_groups,
    'Runs server without specified subscription groups',
    Array,
    %w[
      --exclude_subscription_groups
    ]
  )

  option(
    :exclude_topics,
    'Runs server without specified topics',
    Array,
    %w[
      --exclude_topics
    ]
  )
end

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

aliases, commands, desc, #initialize, load, name, names, option, parse_options

Methods included from Helpers::Colorize

#green, #grey, #red, #yellow

Constructor Details

This class inherits a constructor from Karafka::Cli::Base

Instance Method Details

#callObject

Start the Karafka server



85
86
87
88
89
90
91
92
93
94
# File 'lib/karafka/cli/server.rb', line 85

def call
  # Print our banner and info in the dev mode
  print_marketing_info if Karafka::App.env.development?

  register_inclusions
  register_exclusions

  Karafka::Server.execution_mode = :standalone
  Karafka::Server.run
end

#register_exclusionsObject

Registers things we want to exclude (if defined)



106
107
108
109
110
111
112
# File 'lib/karafka/cli/server.rb', line 106

def register_exclusions
  activity_manager.class::SUPPORTED_TYPES.each do |type|
    names = options[:"exclude_#{type}"] || []

    names.each { |name| activity_manager.exclude(type, name) }
  end
end

#register_inclusionsObject

Registers things we want to include (if defined)



97
98
99
100
101
102
103
# File 'lib/karafka/cli/server.rb', line 97

def register_inclusions
  SUPPORTED_TYPES.each do |type|
    names = options[type] || []

    names.each { |name| activity_manager.include(type, name) }
  end
end