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.
§Arguments
cluster_id- the cluster id, orNoneif unknownnodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hostsunauthorized_topics- the topics the client is not authorized to accessinternal_topics- the internal topics
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.
§Arguments
cluster_id- the cluster id, orNoneif unknownnodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hostsunauthorized_topics- the topics the client is not authorized to accessinternal_topics- the internal topicscontroller- the controller node, orNoneif unknown
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.
§Arguments
cluster_id- the cluster id, orNoneif unknownnodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hostsunauthorized_topics- the topics the client is not authorized to accessinvalid_topics- the topics whose names are invalidinternal_topics- the internal topicscontroller- the controller node, orNoneif unknown
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.
§Arguments
cluster_id- the cluster id, orNoneif unknownnodes- The nodes in the clusterpartitions- Information about a subset of the topic-partitions this cluster hostsunauthorized_topics- the topics the client is not authorized to accessinvalid_topics- the topics whose names are invalidinternal_topics- the internal topicscontroller- the controller node, orNoneif unknowntopic_ids- the topic ids, keyed by topic name
Sourcepub fn bootstrap(addresses: &[(String, SocketAddr)]) -> Self
pub fn bootstrap(addresses: &[(String, SocketAddr)]) -> Self
Sourcepub fn with_partitions(
&self,
partitions: HashMap<TopicPartition, PartitionInfo>,
) -> Self
pub fn with_partitions( &self, partitions: HashMap<TopicPartition, PartitionInfo>, ) -> Self
Returns a copy of this cluster combined with partitions.
§Arguments
partitions- the partitions to add, keyed by topic-partition
Sourcepub fn node_by_id(&self, id: i32) -> Option<&Node>
pub fn node_by_id(&self, id: i32) -> Option<&Node>
Sourcepub fn node_if_online(
&self,
partition: &TopicPartition,
id: i32,
) -> Option<&Node>
pub fn node_if_online( &self, partition: &TopicPartition, id: i32, ) -> Option<&Node>
Sourcepub fn leader_for(&self, topic_partition: &TopicPartition) -> Option<&Node>
pub fn leader_for(&self, topic_partition: &TopicPartition) -> Option<&Node>
Sourcepub fn partition(
&self,
topic_partition: &TopicPartition,
) -> Option<&PartitionInfo>
pub fn partition( &self, topic_partition: &TopicPartition, ) -> Option<&PartitionInfo>
Sourcepub fn partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
pub fn partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
Sourcepub fn partition_count_for_topic(&self, topic: &str) -> Option<usize>
pub fn partition_count_for_topic(&self, topic: &str) -> Option<usize>
Sourcepub fn available_partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
pub fn available_partitions_for_topic(&self, topic: &str) -> &[PartitionInfo]
Sourcepub fn partitions_for_node(&self, node_id: i32) -> &[PartitionInfo]
pub fn partitions_for_node(&self, node_id: i32) -> &[PartitionInfo]
Returns the topics the client is not authorized to access.
Sourcepub fn invalid_topics(&self) -> &HashSet<String>
pub fn invalid_topics(&self) -> &HashSet<String>
Returns the topics whose names are invalid.
Sourcepub fn internal_topics(&self) -> &HashSet<String>
pub fn internal_topics(&self) -> &HashSet<String>
Returns the internal topics.
Sourcepub fn is_bootstrap_configured(&self) -> bool
pub fn is_bootstrap_configured(&self) -> bool
Returns whether this is a bootstrap cluster.
Sourcepub fn cluster_resource(&self) -> &ClusterResource
pub fn cluster_resource(&self) -> &ClusterResource
Returns the cluster resource metadata.
Sourcepub fn controller(&self) -> Option<&Node>
pub fn controller(&self) -> Option<&Node>
Returns the controller node, or None if unknown.
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
Mutably borrows from an owned value. Read more
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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key and return true if they are equal.§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
Checks if this value is equivalent to the given key. Read more