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

Returns true if we are in any of the status that would indicate we should no longer process incoming data. It is a meta status built from others and not a separate state in the sense of a state machine.

Returns:

  • (Boolean)

    true if we are in any of the status that would indicate we should no longer process incoming data. It is a meta status built from others and not a separate state in the sense of a state machine



78
79
80
81
82
83
84
# File 'lib/karafka/status.rb', line 78

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



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

def reset!
  @status = :initializing
end

#to_sString

Returns stringified current app status.

Returns:

  • (String)

    stringified current app status



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

def to_s
  @status.to_s
end