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