Skip to content

Commit bfda6c6

Browse files
authored
fix: improve ReadBatch flush error handling (#16)
- Replace option.is_none() + unwrap() with match pattern - Return ShardLeaderNotFound error to inflight operations instead of silently dropping them when shard leader is not found Signed-off-by: mattisonchao <mattisonchao@gmail.com>
1 parent 9fa6bb9 commit bfda6c6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

liboxia-native/src/batch.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ impl ReadBatch {
8484
}
8585

8686
async fn flush(&mut self) {
87-
let option = self.shard_manager.get_leader(self.shard_id);
88-
if option.is_none() {
89-
return;
90-
}
91-
let node = option.unwrap();
87+
let node = match self.shard_manager.get_leader(self.shard_id) {
88+
Some(node) => node,
89+
None => {
90+
self.failure_inflight(OxiaError::ShardLeaderNotFound(self.shard_id));
91+
return;
92+
}
93+
};
9294
match self
9395
.provider_manager
9496
.get_provider(node.service_address)

0 commit comments

Comments
 (0)