pub struct Cluster { /* private fields */ }Expand description
An immutable representation of a subset of the nodes, topics, and partitions in the Kafka cluster.
Implementations§
Source§impl Cluster
impl Cluster
Sourcepub fn new(
cluster_id: Option<String>,
nodes: Vec<Node>,
partitions: Vec<PartitionInfo>,
unauthorized_topics: HashSet<String>,
internal_topics: HashSet<String>,
) -> Self
pub fn new( cluster_id: Option<String>, nodes: Vec<Node>, partitions: Vec<PartitionInfo>, unauthorized_topics: HashSet<String>, internal_topics: HashSet<String>, ) -> Self
Create a new cluster with the given id, nodes and partitions.
Corresponds to Java’s
Cluster(String, Collection<Node>, Collection<PartitionInfo>, Set<String>, Set<String>)
(Cluster.java:57), whose parameters
{clusterId, nodes, partitions, unauthorizedTopics, internalTopics} are
the intersection across the four public constructors — so it owns the
plain name (CLAUDE.md §2).
§Arguments
nodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hosts
Sourcepub fn with_controller(
cluster_id: Option<String>,
nodes: Vec<Node>,
partitions: Vec<PartitionInfo>,
unauthorized_topics: HashSet<String>,
internal_topics: HashSet<String>,
controller: Option<Node>,
) -> Self
pub fn with_controller( cluster_id: Option<String>, nodes: Vec<Node>, partitions: Vec<PartitionInfo>, unauthorized_topics: HashSet<String>, internal_topics: HashSet<String>, controller: Option<Node>, ) -> Self
Create a new cluster with the given id, nodes, partitions and controller.
Corresponds to Java’s
Cluster(String, Collection<Node>, Collection<PartitionInfo>, Set<String>, Set<String>, Node)
(Cluster.java:70).
§Arguments
nodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hosts
Sourcepub fn with_invalid_topics_controller(
cluster_id: Option<String>,
nodes: Vec<Node>,
partitions: Vec<PartitionInfo>,
unauthorized_topics: HashSet<String>,
invalid_topics: HashSet<String>,
internal_topics: HashSet<String>,
controller: Option<Node>,
) -> Self
pub fn with_invalid_topics_controller( cluster_id: Option<String>, nodes: Vec<Node>, partitions: Vec<PartitionInfo>, unauthorized_topics: HashSet<String>, invalid_topics: HashSet<String>, internal_topics: HashSet<String>, controller: Option<Node>, ) -> Self
Create a new cluster with the given id, nodes, partitions, invalid topics and controller.
Corresponds to Java’s
Cluster(String, Collection<Node>, Collection<PartitionInfo>, Set<String>, Set<String>, Set<String>, Node)
(Cluster.java:84).
§Arguments
nodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hosts
Sourcepub fn with_invalid_topics_controller_topic_ids(
cluster_id: Option<String>,
nodes: Vec<Node>,
partitions: Vec<PartitionInfo>,
unauthorized_topics: HashSet<String>,
invalid_topics: HashSet<String>,
internal_topics: HashSet<String>,
controller: Option<Node>,
topic_ids: HashMap<String, Uuid>,
) -> Self
pub fn with_invalid_topics_controller_topic_ids( cluster_id: Option<String>, nodes: Vec<Node>, partitions: Vec<PartitionInfo>, unauthorized_topics: HashSet<String>, invalid_topics: HashSet<String>, internal_topics: HashSet<String>, controller: Option<Node>, topic_ids: HashMap<String, Uuid>, ) -> Self
Create a new cluster with the given id, nodes, partitions and topic ids.
Corresponds to Java’s widest public constructor (Cluster.java:99).
§Arguments
nodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hosts
Sourcepub fn bootstrap(addresses: &[(String, SocketAddr)]) -> Self
pub fn bootstrap(addresses: &[(String, SocketAddr)]) -> Self
Create a “bootstrap” cluster using the given list of (hostname, address) pairs.
Sourcepub fn with_partitions(
&self,
partitions: HashMap<TopicPartition, PartitionInfo>,
) -> Self
pub fn with_partitions( &self, partitions: HashMap<TopicPartition, PartitionInfo>, ) -> Self
Return a copy of this cluster combined with additional partitions.
Sourcepub fn node_by_id(&self, id: i32) -> Option<&Node>
pub fn node_by_id(&self, id: i32) -> Option<&Node>
Get the node by the node id (or None if the node is not online or does not exist).
Sourcepub fn node_if_online(
&self,
partition: &TopicPartition,
id: i32,
) -> Option<&Node>
pub fn node_if_online( &self, partition: &TopicPartition, id: i32, ) -> Option<&Node>
Get the node by node id if the replica for the given partition is online.
Sourcepub fn leader_for(&self, topic_partition: &TopicPartition) -> Option<&Node>
pub fn leader_for(&self, topic_partition: &TopicPartition) -> Option<&Node>
Get the current leader for the given topic-partition.
Sourcepub fn partition(
&self,
topic_partition: &TopicPartition,
) -> Option<&PartitionInfo>
pub fn partition( &self, topic_partition: &TopicPartition, ) -> Option<&PartitionInfo>
Get the metadata for the specified partition.
Sourcepub fn partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
pub fn partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
Get the list of partitions for this topic.
Sourcepub fn partition_count_for_topic(&self, topic: &str) -> Option<usize>
pub fn partition_count_for_topic(&self, topic: &str) -> Option<usize>
Get the number of partitions for the given topic.
Sourcepub fn available_partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
pub fn available_partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
Get the list of available partitions for this topic.
Sourcepub fn partitions_for_node(&self, node_id: i32) -> &[PartitionInfo]
pub fn partitions_for_node(&self, node_id: i32) -> &[PartitionInfo]
Get the list of partitions whose leader is this node.
Unauthorized topics.
Sourcepub fn invalid_topics(&self) -> &HashSet<String>
pub fn invalid_topics(&self) -> &HashSet<String>
Invalid topics.
Sourcepub fn internal_topics(&self) -> &HashSet<String>
pub fn internal_topics(&self) -> &HashSet<String>
Internal topics.
Sourcepub fn is_bootstrap_configured(&self) -> bool
pub fn is_bootstrap_configured(&self) -> bool
Whether bootstrap is configured.
Sourcepub fn cluster_resource(&self) -> &ClusterResource
pub fn cluster_resource(&self) -> &ClusterResource
The cluster resource metadata.
Sourcepub fn controller(&self) -> Option<&Node>
pub fn controller(&self) -> Option<&Node>
The controller node, if known.
Sourcepub fn topic_name(&self, topic_id: &Uuid) -> Option<&str>
pub fn topic_name(&self, topic_id: &Uuid) -> Option<&str>
Get the topic name for a given topic ID.
Trait Implementations§
impl Eq for Cluster
Auto Trait Implementations§
impl Freeze for Cluster
impl RefUnwindSafe for Cluster
impl Send for Cluster
impl Sync for Cluster
impl Unpin for Cluster
impl UnsafeUnpin for Cluster
impl UnwindSafe for Cluster
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.