From cd323f87d9ab22ac1af1718ec342c3fa63838b3e Mon Sep 17 00:00:00 2001 From: Flash Date: Sat, 23 Dec 2023 18:51:10 +0800 Subject: [PATCH] feat: make services-gdrive compile for wasm target (#3808) --- .github/workflows/ci.yml | 3 ++- core/src/services/gdrive/backend.rs | 3 ++- core/src/services/gdrive/lister.rs | 3 ++- core/src/services/gdrive/writer.rs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 091893e528e..6bd9a3b84d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -293,7 +293,7 @@ jobs: ) cargo build --features "${FEATURES[*]}" - # We only support s3 services for now, but we will extend wasm support for other services. + # We only support some services(see `available_services` below) for now, but we will extend wasm support for other services. build_under_wasm: runs-on: ubuntu-latest steps: @@ -306,6 +306,7 @@ jobs: run: | available_services=( services-azblob + services-gdrive services-s3 ) IFS="," diff --git a/core/src/services/gdrive/backend.rs b/core/src/services/gdrive/backend.rs index fd83d96fa24..3e88e912ca6 100644 --- a/core/src/services/gdrive/backend.rs +++ b/core/src/services/gdrive/backend.rs @@ -39,7 +39,8 @@ pub struct GdriveBackend { pub core: Arc, } -#[async_trait] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] impl Accessor for GdriveBackend { type Reader = IncomingAsyncBody; type BlockingReader = (); diff --git a/core/src/services/gdrive/lister.rs b/core/src/services/gdrive/lister.rs index b8cf78a8eaf..9da239035d6 100644 --- a/core/src/services/gdrive/lister.rs +++ b/core/src/services/gdrive/lister.rs @@ -37,7 +37,8 @@ impl GdriveLister { } } -#[async_trait] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] impl oio::PageList for GdriveLister { async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> { let file_id = self.core.get_file_id_by_path(&self.path).await?; diff --git a/core/src/services/gdrive/writer.rs b/core/src/services/gdrive/writer.rs index 445ecb36f7c..f902ed2559c 100644 --- a/core/src/services/gdrive/writer.rs +++ b/core/src/services/gdrive/writer.rs @@ -87,7 +87,8 @@ impl GdriveWriter { } } -#[async_trait] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] impl oio::OneShotWrite for GdriveWriter { async fn write_once(&self, bs: &dyn WriteBuf) -> Result<()> { let bs = bs.bytes(bs.remaining());