This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch stream-based-write in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 596ddfc068921b3e20436c6eabd5ac7dc9920caf Author: Xuanwo <[email protected]> AuthorDate: Wed Aug 30 18:38:53 2023 +0800 Migrate ghac Signed-off-by: Xuanwo <[email protected]> --- core/src/services/ghac/writer.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/core/src/services/ghac/writer.rs b/core/src/services/ghac/writer.rs index 83bde0bb3..a9fcff2e5 100644 --- a/core/src/services/ghac/writer.rs +++ b/core/src/services/ghac/writer.rs @@ -38,12 +38,15 @@ impl GhacWriter { size: 0, } } +} - async fn write(&mut self, bs: Bytes) -> Result<()> { - let size = bs.len() as u64; +#[async_trait] +impl oio::Write for GhacWriter { + async fn write(&mut self, s: oio::Streamer) -> Result<()> { + let size = s.size(); let req = self .backend - .ghac_upload(self.cache_id, size, AsyncBody::Bytes(bs)) + .ghac_upload(self.cache_id, size, AsyncBody::Stream(s)) .await?; let resp = self.backend.client.send(req).await?; @@ -58,16 +61,6 @@ impl GhacWriter { .map(|err| err.with_operation("Backend::ghac_upload"))?) } } -} - -#[async_trait] -impl oio::Write for GhacWriter { - async fn write(&mut self, _s: oio::Streamer) -> Result<()> { - Err(Error::new( - ErrorKind::Unsupported, - "Write::sink is not supported", - )) - } async fn abort(&mut self) -> Result<()> { Ok(())
