Class: Karafka::Status

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

Overview

App status monitor

Constant Summary collapse

STATES =

Available states and their transitions.

{
  initializing: :initialize!,
  initialized: :initialized!,
  supervising: :supervise!,
  running: :run!,
  # will no longer pickup any work, but current work will be finished
  quieting: :quiet!,
  # no work is happening but we keep process with the assignments running
  quiet: :quieted!,
  # shutdown started
  stopping: :stop!,
  # all things are done and most of the things except critical are closed
  stopped: :stopped!,
  # immediately after this process exists
  terminated: :terminate!
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeStatus

By default we are in the initializing state



35
36
37
# File 'lib/karafka/status.rb', line 35

def initialize
  initialize!
end

Instance Method Details

#done?Boolean



82
83
84
85
86
87
88
# File 'lib/karafka/status.rb', line 82

def done?
  # Short-track for the most common case not to invoke all others on normal execution
  return false if running?
  return false if supervising?

  stopping? || stopped? || quieting? || quiet? || terminated?
end

#reset!Object

Resets the status state This is used mostly in the integration suite



45
46
47
# File 'lib/karafka/status.rb', line 45

def reset!
  @status = :initializing
end

#to_sString



40
41
42
# File 'lib/karafka/status.rb', line 40

def to_s
  @status.to_s
end