review: move FlushHandle::handle_error right after ::flush

Signed-off-by: Yuchen Liang <yuchen@neon.tech>
This commit is contained in:
Yuchen Liang
2024-12-02 16:31:44 +00:00
parent a439d57050
commit 6a1aa52619

View File

@@ -175,6 +175,13 @@ where
Ok((recycled, flush_control))
}
async fn handle_error<T>(&mut self) -> std::io::Result<T> {
Err(self
.shutdown()
.await
.expect_err("flush task only disconnects duplex if it exits with an error"))
}
/// Cleans up the channel, join the flush task.
pub async fn shutdown(&mut self) -> std::io::Result<Arc<W>> {
let handle = self
@@ -192,10 +199,6 @@ where
.as_mut()
.expect("must not use after we returned an error")
}
async fn handle_error<T>(&mut self) -> std::io::Result<T> {
Err(self.shutdown().await.expect_err("flush task only disconnects duplex if it exits with an error"))
}
}
/// A background task for flushing data to disk.