Skip to content

Commit 9122783

Browse files
Merge pull request #154 from influxdata/crepererum/partition_client_getters
feat: add some getters to `PartitionClient`
2 parents a8386ed + 3bcf782 commit 9122783

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/client/partition.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ impl PartitionClient {
101101
}
102102
}
103103

104+
/// Topic
105+
pub fn topic(&self) -> &str {
106+
&self.topic
107+
}
108+
109+
/// Partition
110+
pub fn partition(&self) -> i32 {
111+
self.partition
112+
}
113+
104114
/// Produce a batch of records to the partition
105115
pub async fn produce(
106116
&self,

tests/client.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ async fn test_topic_crud() {
7070
}
7171
}
7272

73+
#[tokio::test]
74+
async fn test_partition_client() {
75+
maybe_start_logging();
76+
77+
let connection = maybe_skip_kafka_integration!();
78+
let topic_name = random_topic_name();
79+
80+
let client = ClientBuilder::new(connection).build().await.unwrap();
81+
82+
let controller_client = client.controller_client().unwrap();
83+
controller_client
84+
.create_topic(&topic_name, 1, 1, 5_000)
85+
.await
86+
.unwrap();
87+
88+
let partition_client = client.partition_client(topic_name.clone(), 0).unwrap();
89+
assert_eq!(partition_client.topic(), &topic_name);
90+
assert_eq!(partition_client.partition(), 0);
91+
}
92+
7393
// Disabled as currently no TLS integration tests
7494
#[ignore]
7595
#[tokio::test]

0 commit comments

Comments
 (0)