Skip to content

Commit

Permalink
introduce another mode for EdenFs CAS client with private cache
Browse files Browse the repository at this point in the history
Summary:
introduce another mode for EdenFs CAS client - the Rich client with "private cache"

there are no plans to use this mode in prod, however we would like to have it for testing purposes

Reviewed By: Skory

Differential Revision: D66650503

fbshipit-source-id: c1dced81f987529bd896e15bd15d1cb432833f25
  • Loading branch information
Liubov Dmitrieva authored and facebook-github-bot committed Dec 2, 2024
1 parent eaad01d commit 1fb9ca5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions eden/scm/lib/cas-client/rich-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub struct RichCasClient {
fetch_limit: ByteCount,
fetch_concurrency: usize,
use_streaming_dowloads: bool,
private_cache_path: Option<String>,
private_cache_size: ByteCount,
}

pub fn init() {
Expand Down Expand Up @@ -96,6 +98,16 @@ impl RichCasClient {

let default_fetch_limit = ByteCount::try_from_str("200MB")?;

let private_cache_path = config.get_opt::<String>("cas", "private-cache-path")?;
if private_cache_path.is_some() && use_casd_cache {
return Err(anyhow::anyhow!(
"cas.private-cache-path and cas.use-shared-cache cannot be used together"
));
}
let default_private_cache_size = ByteCount::try_from_str("100GB")?;
let private_cache_size = config
.get_or::<ByteCount>("cas", "private-cache-size", || default_private_cache_size)?;

Ok(Some(Self {
client: Default::default(),
verbose: config.get_or_default("cas", "verbose")?,
Expand All @@ -109,6 +121,8 @@ impl RichCasClient {
.get_or::<ByteCount>("cas", "max-batch-bytes", || default_fetch_limit)?,
fetch_concurrency: config.get_or("cas", "fetch-concurrency", || 4)?,
use_streaming_dowloads: config.get_or("cas", "use-streaming-downloads", || true)?,
private_cache_path,
private_cache_size,
}))
}

Expand Down Expand Up @@ -154,6 +168,17 @@ impl RichCasClient {
embedded_config.remote_cache_config = Some(remote_cache_config);
embedded_config.cache_config.writable_cache = false;
}
// We check that the modes use_casd_cache and private_cache_path do not conflict while parcing the sapling config.
// So, if we are here, we know that the private cache is enabled.
if let Some(ref private_cache_path) = self.private_cache_path {
embedded_config.cache_config.downloads_cache_config.dir_path =
Some(private_cache_path.clone());
embedded_config
.cache_config
.downloads_cache_config
.size_bytes = self.private_cache_size.value() as i64;
embedded_config.cache_config.writable_cache = true;
}
re_config.cas_client_config = CASDaemonClientCfg::embedded_config(embedded_config);

let builder = REClientBuilder::new(fbinit::expect_init())
Expand Down

0 comments on commit 1fb9ca5

Please sign in to comment.