Skip to content

Commit

Permalink
modern sync: add upload_trees method
Browse files Browse the repository at this point in the history
Summary: Unused for now, this is prep for sending hg data

Reviewed By: andreacampi

Differential Revision: D67006514

fbshipit-source-id: a554ca3523aff387f8e88e6fe7d32a4970870b3e
  • Loading branch information
lmvasquezg authored and facebook-github-bot committed Dec 11, 2024
1 parent 0d60251 commit 3937878
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions eden/mononoke/modern_sync/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use anyhow::Result;
use async_trait::async_trait;
use edenapi_types::UploadTreeEntry;
use mononoke_types::ContentId;
use mononoke_types::FileContents;
pub mod dummy;
Expand All @@ -15,4 +16,7 @@ pub mod edenapi;
#[async_trait]
pub trait ModernSyncSender {
async fn upload_content(&self, content_id: ContentId, _blob: FileContents) -> Result<()>;

#[allow(unused)]
async fn upload_tree(&self, trees: Vec<UploadTreeEntry>) -> Result<()>;
}
8 changes: 8 additions & 0 deletions eden/mononoke/modern_sync/src/sender/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use anyhow::Result;
use async_trait::async_trait;
use edenapi_types::UploadTreeEntry;
use mononoke_types::ContentId;
use mononoke_types::FileContents;
use slog::info;
Expand All @@ -31,4 +32,11 @@ impl ModernSyncSender for DummySender {
info!(&self.logger, "Uploading content with id: {:?}", content_id);
Ok(())
}

async fn upload_tree(&self, trees: Vec<UploadTreeEntry>) -> Result<()> {
for tree in trees {
info!(&self.logger, "Uploading tree with id {:?}", tree.node_id);
}
Ok(())
}
}
11 changes: 11 additions & 0 deletions eden/mononoke/modern_sync/src/sender/edenapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use edenapi::HttpClientBuilder;
use edenapi::HttpClientConfig;
use edenapi::SaplingRemoteApi;
use edenapi_types::AnyFileContentId;
use edenapi_types::UploadTreeEntry;
use futures::TryStreamExt;
use mononoke_app::args::TLSArgs;
use mononoke_types::FileContents;
Expand Down Expand Up @@ -99,4 +100,14 @@ impl ModernSyncSender for EdenapiSender {

Ok(())
}

async fn upload_tree(&self, trees: Vec<UploadTreeEntry>) -> Result<()> {
let res = self.client.upload_trees_batch(trees).await?;
info!(
&self.logger,
"Upload tree response: {:?}",
res.entries.try_collect::<Vec<_>>().await?
);
Ok(())
}
}

0 comments on commit 3937878

Please sign in to comment.