Skip to main content

xet_data/processing/
remote_client_interface.rs

1use std::sync::Arc;
2
3use xet_client::cas_client::{Client, RemoteClient};
4
5use super::configurations::TranslatorConfig;
6use crate::error::Result;
7
8pub async fn create_remote_client(
9    config: &TranslatorConfig,
10    session_id: &str,
11    dry_run: bool,
12) -> Result<Arc<dyn Client>> {
13    let session = &config.session;
14    let runtime = config.ctx.clone();
15
16    if let Some(local_path) = session.local_path(&config.ctx) {
17        #[cfg(not(target_family = "wasm"))]
18        {
19            let xorb_path = local_path.join("xet").join("xorbs");
20            Ok(xet_client::cas_client::LocalClient::new(runtime, xorb_path).await?)
21        }
22        #[cfg(target_family = "wasm")]
23        {
24            let _ = local_path;
25            unimplemented!("Local file system access is not available in WASM")
26        }
27    } else if session.is_memory() {
28        Ok(xet_client::cas_client::MemoryClient::new(runtime))
29    } else {
30        Ok(RemoteClient::new(
31            runtime,
32            &session.endpoint,
33            &session.auth,
34            session_id,
35            dry_run,
36            session.custom_headers.clone(),
37        ))
38    }
39}