walker: specify cache-mode default

Summary: Walker previously specified a default for the deprecated `cachelib-only-blobstore` argument.  Switch to `cache-mode`, allowing us to specify local caching for all types, not just the blobstore.

Differential Revision: D45089769

fbshipit-source-id: 978ac545590935be5a825669db9df58f0281c41a
This commit is contained in:
Mark Juggurnauth-Thomas 2023-06-16 03:21:13 -07:00 committed by Facebook GitHub Bot
parent 0299d9bb5f
commit 32d13cc799
3 changed files with 16 additions and 1 deletions

View File

@ -9,6 +9,7 @@ license = "GPLv2+"
[dependencies]
anyhow = "1.0.65"
arg_extensions = { version = "0.1.0", path = "../extensions" }
cachelib = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
clap = { version = "4.2.4", features = ["derive", "env", "string", "unicode", "wrap_help"] }
environment = { version = "0.1.0", path = "../environment" }

View File

@ -5,6 +5,7 @@
* GNU General Public License version 2.
*/
use arg_extensions::ArgDefaults;
use clap::ArgAction;
use clap::Args;
use clap::ValueEnum;
@ -21,6 +22,18 @@ pub enum CacheMode {
Disabled,
}
impl ArgDefaults for CacheMode {
fn arg_defaults(&self) -> Vec<(&'static str, String)> {
vec![(
"cache_mode",
self.to_possible_value()
.expect("default value must exist")
.get_name()
.to_string(),
)]
}
}
#[derive(Args, Debug)]
pub struct CachelibArgs {
/// Mode to initialize caching in.

View File

@ -19,6 +19,7 @@ use blobstore_factory::BlobstoreArgDefaults;
use blobstore_factory::ReadOnlyStorage;
use clap::ArgGroup;
use clap::Parser;
use cmdlib_caching::CacheMode;
use cmdlib_caching::CachelibSettings;
use cmdlib_scrubbing::ScrubAppExtension;
use fbinit::FacebookInit;
@ -63,7 +64,6 @@ fn main(fb: FacebookInit) -> Result<(), Error> {
let cachelib_defaults = CachelibSettings {
cache_size: 2 * 1024 * 1024 * 1024,
blobstore_cachelib_only: true,
..Default::default()
};
@ -85,6 +85,7 @@ fn main(fb: FacebookInit) -> Result<(), Error> {
let app = MononokeAppBuilder::new(fb)
.with_app_extension(scrub_extension)
.with_default_cachelib_settings(cachelib_defaults)
.with_arg_defaults(CacheMode::LocalOnly)
.with_arg_defaults(blobstore_defaults)
.with_arg_defaults(read_only_storage)
.with_app_extension(Fb303AppExtension {})