Class: Karafka::Web::Ui::Models::Broker
- Inherits:
-
Lib::HashProxy
- Object
- Lib::HashProxy
- Karafka::Web::Ui::Models::Broker
- Defined in:
- lib/karafka/web/ui/models/broker.rb
Overview
Represents a single broker data within the cluster
Class Method Summary collapse
-
.all ⇒ Array<Broker>
All brokers in the cluster.
-
.find(broker_id) ⇒ Broker
Finds requested broker.
Instance Method Summary collapse
-
#configs ⇒ Array<Karafka::Admin::Configs::Config>
All broker configs.
-
#full_name ⇒ String
Full broker name for presentation.
- #id ⇒ Integer
- #name ⇒ String
- #port ⇒ Integer
Methods inherited from Lib::HashProxy
#initialize, #method_missing, #respond_to_missing?, #to_h
Constructor Details
This class inherits a constructor from Karafka::Web::Ui::Lib::HashProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Karafka::Web::Ui::Lib::HashProxy
Class Method Details
.all ⇒ Array<Broker>
Returns all brokers in the cluster.
11 12 13 14 15 16 |
# File 'lib/karafka/web/ui/models/broker.rb', line 11 def all # We do not cache here because we want the most recent state of brokers possible ClusterInfo.fetch(cached: false).brokers.map do |broker| new(broker) end end |
Instance Method Details
#configs ⇒ Array<Karafka::Admin::Configs::Config>
Returns all broker configs.
53 54 55 56 57 58 59 60 61 |
# File 'lib/karafka/web/ui/models/broker.rb', line 53 def configs # We copy the array because the result one is frozen and we sort @configs ||= ::Karafka::Admin::Configs.describe( ::Karafka::Admin::Configs::Resource.new( type: :broker, name: id ) ).first.configs.dup end |
#full_name ⇒ String
Returns full broker name for presentation.
48 49 50 |
# File 'lib/karafka/web/ui/models/broker.rb', line 48 def full_name "#{id} - #{name}:#{port}" end |
#id ⇒ Integer
33 34 35 |
# File 'lib/karafka/web/ui/models/broker.rb', line 33 def id broker_id end |
#name ⇒ String
38 39 40 |
# File 'lib/karafka/web/ui/models/broker.rb', line 38 def name broker_name end |
#port ⇒ Integer
43 44 45 |
# File 'lib/karafka/web/ui/models/broker.rb', line 43 def port broker_port end |