Class: Karafka::Web::Ui::Models::ClusterInfo
- Inherits:
-
Object
- Object
- Karafka::Web::Ui::Models::ClusterInfo
- Defined in:
- lib/karafka/web/ui/models/cluster_info.rb
Overview
Wraps around the Lib::Admin#cluster_info
with caching and some additional aliases so we can reference relevant information easily
Class Method Summary collapse
-
.fetch ⇒ Rdkafka::Metadata
Gets us all the cluster metadata info.
-
.partitions_count(topic_name) ⇒ Integer
Number of partitions in a given topic.
-
.topic(topic_name) ⇒ Ui::Models::Topic
Fetches us details about particular topic.
-
.topics ⇒ Array<Ui::Models::Topic>
Returns us all the info about available topics from the cluster.
Class Method Details
.fetch ⇒ Rdkafka::Metadata
Gets us all the cluster metadata info
14 15 16 17 18 |
# File 'lib/karafka/web/ui/models/cluster_info.rb', line 14 def fetch Karafka::Web.config.ui.cache.fetch(:cluster_info) do Lib::Admin.cluster_info end end |
.partitions_count(topic_name) ⇒ Integer
Returns number of partitions in a given topic.
45 46 47 |
# File 'lib/karafka/web/ui/models/cluster_info.rb', line 45 def partitions_count(topic_name) topic(topic_name).partition_count end |
.topic(topic_name) ⇒ Ui::Models::Topic
Fetches us details about particular topic
33 34 35 36 37 38 39 40 41 |
# File 'lib/karafka/web/ui/models/cluster_info.rb', line 33 def topic(topic_name) Lib::Admin .topic_info(topic_name) .then { |topic| Topic.new(topic) } rescue Rdkafka::RdkafkaError => e raise e unless e.code == :unknown_topic_or_part raise(Web::Errors::Ui::NotFoundError, topic_name) end |
.topics ⇒ Array<Ui::Models::Topic>
Returns us all the info about available topics from the cluster
23 24 25 26 27 |
# File 'lib/karafka/web/ui/models/cluster_info.rb', line 23 def topics fetch .topics .map { |topic| Topic.new(topic) } end |