Sha256: 91a660f9eac527d165a562119a6b5420a74609920875942bbf369944d52ec07d
Contents?: true
Size: 1.38 KB
Versions: 8
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module Karafka module Web module Ui module Models # Model representing the current consumers metrics most recent state class ConsumersMetrics < Lib::HashProxy class << self # @return [State, false] current consumers metrics or false if not found def current state = fetch return false unless state # Do not return the state in case web-ui is not enabled because we need our # internal deserializer for it to operate. False will force user to go to the # status page return false unless Models::Status.new.enabled.success? state = state.payload new(state) end # @return [State] current consumers metrics # @raise [::Karafka::Web::Errors::Ui::NotFoundError] raised when there is no metrics. def current! current || raise(::Karafka::Web::Errors::Ui::NotFoundError) end private # @return [::Karafka::Messages::Message, nil] most recent state or nil if none def fetch ::Karafka::Admin.read_topic( Karafka::Web.config.topics.consumers.metrics, 0, 1 ).last end end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems