Skip to content

Commit 2e1d918

Browse files
committed
feat: implement Display trait for FlushRegions
Signed-off-by: WenyXu <[email protected]>
1 parent fdab75c commit 2e1d918

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/common/meta/src/instruction.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,16 @@ pub struct FlushRegions {
339339
pub error_strategy: FlushErrorStrategy,
340340
}
341341

342+
impl Display for FlushRegions {
343+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
344+
write!(
345+
f,
346+
"FlushRegions(region_ids={:?}, strategy={:?}, error_strategy={:?})",
347+
self.region_ids, self.strategy, self.error_strategy
348+
)
349+
}
350+
}
351+
342352
impl FlushRegions {
343353
/// Create synchronous single-region flush
344354
pub fn sync_single(region_id: RegionId) -> Self {

src/datanode/src/heartbeat/handler/flush_region.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,15 @@ mod tests {
320320
assert!(flush_reply.results[0].1.is_ok());
321321
assert!(flush_reply.results[1].1.is_err());
322322
}
323+
324+
#[test]
325+
fn test_flush_regions_display() {
326+
let region_id = RegionId::new(1024, 1);
327+
let flush_regions = FlushRegions::sync_single(region_id);
328+
let display = format!("{}", flush_regions);
329+
assert_eq!(
330+
display,
331+
"FlushRegions(region_ids=[4398046511105(1024, 1)], strategy=Sync, error_strategy=FailFast)"
332+
);
333+
}
323334
}

0 commit comments

Comments
 (0)