|
| 1 | +//! Cluster-wide Kafka metadata. |
| 2 | +
|
| 3 | +/// Metadata container for the entire cluster. |
| 4 | +#[derive(Debug, PartialEq)] |
| 5 | +pub struct Metadata { |
| 6 | + /// Brokers. |
| 7 | + pub brokers: Vec<MetadataBroker>, |
| 8 | + |
| 9 | + /// The ID of the controller broker. |
| 10 | + pub controller_id: Option<i32>, |
| 11 | + |
| 12 | + /// Topics. |
| 13 | + pub topics: Vec<MetadataTopic>, |
| 14 | +} |
| 15 | + |
| 16 | +/// Metadata for a certain broker. |
| 17 | +#[derive(Debug, PartialEq)] |
| 18 | +pub struct MetadataBroker { |
| 19 | + /// The broker ID |
| 20 | + pub node_id: i32, |
| 21 | + |
| 22 | + /// The broker hostname |
| 23 | + pub host: String, |
| 24 | + |
| 25 | + /// The broker port |
| 26 | + pub port: i32, |
| 27 | + |
| 28 | + /// Rack. |
| 29 | + pub rack: Option<String>, |
| 30 | +} |
| 31 | + |
| 32 | +/// Metadata for a certain topic. |
| 33 | +#[derive(Debug, PartialEq)] |
| 34 | +pub struct MetadataTopic { |
| 35 | + /// The topic name |
| 36 | + pub name: String, |
| 37 | + |
| 38 | + /// True if the topic is internal |
| 39 | + pub is_internal: Option<bool>, |
| 40 | + |
| 41 | + /// Each partition in the topic |
| 42 | + pub partitions: Vec<MetadataPartition>, |
| 43 | +} |
| 44 | + |
| 45 | +/// Metadata for a certain partition. |
| 46 | +#[derive(Debug, PartialEq)] |
| 47 | +pub struct MetadataPartition { |
| 48 | + /// The partition index |
| 49 | + pub partition_index: i32, |
| 50 | + |
| 51 | + /// The ID of the leader broker |
| 52 | + pub leader_id: i32, |
| 53 | + |
| 54 | + /// The set of all nodes that host this partition |
| 55 | + pub replica_nodes: Vec<i32>, |
| 56 | + |
| 57 | + /// The set of all nodes that are in sync with the leader for this partition |
| 58 | + pub isr_nodes: Vec<i32>, |
| 59 | +} |
0 commit comments