Sha256: 35451f4aa3f4063b8502bce58ddd41c0ce73ec7d5e86cbacbb2b1c606d718f48

Contents?: true

Size: 710 Bytes

Versions: 27

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module Karafka
  # App status monitor
  class Status
    # Available states and their transitions
    STATES = {
      initializing: :initialize!,
      initialized: :initialized!,
      running: :run!,
      stopping: :stop!
    }.freeze

    private_constant :STATES

    STATES.each do |state, transition|
      define_method :"#{state}?" do
        @status == state
      end

      define_method transition do
        @status = state
        # Trap context disallows to run certain things that we instrument
        # so the state changes are executed from a separate thread
        Thread.new { Karafka.monitor.instrument("app.#{state}") }.join
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
karafka-1.4.15 lib/karafka/status.rb
karafka-1.4.14 lib/karafka/status.rb
karafka-1.4.13 lib/karafka/status.rb
karafka-1.4.12 lib/karafka/status.rb
karafka-1.4.11 lib/karafka/status.rb
karafka-1.4.10 lib/karafka/status.rb
karafka-1.4.9 lib/karafka/status.rb
karafka-1.4.8 lib/karafka/status.rb
karafka-1.4.7 lib/karafka/status.rb
karafka-1.4.6 lib/karafka/status.rb
karafka-1.4.5 lib/karafka/status.rb
karafka-1.4.4 lib/karafka/status.rb
karafka-1.4.3 lib/karafka/status.rb
karafka-1.4.2 lib/karafka/status.rb
karafka-1.4.1 lib/karafka/status.rb
karafka-1.4.0 lib/karafka/status.rb
karafka-1.4.0.rc2 lib/karafka/status.rb
karafka-1.4.0.rc1 lib/karafka/status.rb
karafka-1.3.7 lib/karafka/status.rb
karafka-1.3.6 lib/karafka/status.rb