Class: Karafka::Server

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

Overview

Karafka consuming server class

Constant Summary collapse

SUPERVISION_SLEEP =

How long should we sleep between checks on shutting down consumers

1
FORCEFUL_EXIT_CODE =

What system exit code should we use when we terminated forcefully

2

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.consumer_groupsArray<String>

Returns array with names of consumer groups that should be consumed in a current server context.

Returns:

  • (Array<String>)

    array with names of consumer groups that should be consumed in a current server context



30
31
32
33
# File 'lib/karafka/server.rb', line 30

def consumer_groups
  # If not specified, a server will listed on all the topics
  @consumer_groups ||= Karafka::App.consumer_groups.map(&:name).freeze
end

.consumer_threadsObject

Set of consuming threads. Each consumer thread contains a single consumer



15
16
17
# File 'lib/karafka/server.rb', line 15

def consumer_threads
  @consumer_threads
end

Class Method Details

.runObject

Method which runs app



21
22
23
24
25
26
# File 'lib/karafka/server.rb', line 21

def run
  process.on_sigint { stop_supervised }
  process.on_sigquit { stop_supervised }
  process.on_sigterm { stop_supervised }
  start_supervised
end