diff --git a/Cargo.toml b/Cargo.toml index 55a29c453..fc0493570 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ members = [ "shed/hash_memo", "shed/hostcaps", "shed/hostname", + "shed/justknobs_stub", "shed/limited_async_read", "shed/lock_ext", "shed/memcache_stub", diff --git a/shed/justknobs_stub/Cargo.toml b/shed/justknobs_stub/Cargo.toml new file mode 100644 index 000000000..5333c7973 --- /dev/null +++ b/shed/justknobs_stub/Cargo.toml @@ -0,0 +1,14 @@ +# @generated by autocargo + +[package] +name = "justknobs" +version = "0.1.0" +authors = ["Facebook "] +edition = "2021" +description = "Client for accessing JustKnobs. Noop crate for now" +readme = "../../README.md" +repository = "https://github.com/facebookexperimental/rust-shed/" +license = "MIT OR Apache-2.0" + +[dependencies] +anyhow = "=1.0.72" diff --git a/shed/justknobs_stub/src/lib.rs b/shed/justknobs_stub/src/lib.rs new file mode 100644 index 000000000..6d9d48aac --- /dev/null +++ b/shed/justknobs_stub/src/lib.rs @@ -0,0 +1,38 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under both the MIT license found in the + * LICENSE-MIT file in the root directory of this source tree and the Apache + * License, Version 2.0 found in the LICENSE-APACHE file in the root directory + * of this source tree. + */ + +//! This crate provides a client for accessing JustKnobs. The version on GitHub +//! is no-op for now. + +use anyhow as _; +#[cfg(fbcode_build)] +pub use fb_justknobs::*; +#[cfg(not(fbcode_build))] +pub use stub::*; + +#[cfg(not(fbcode_build))] +mod stub { + use anyhow::Result; + + pub fn eval(_name: &str, _hash_val: Option<&str>, _switch_val: Option<&str>) -> Result { + Ok(false) + } + + pub fn get(_name: &str, _switch_val: Option<&str>) -> Result { + Ok(0) + } + + pub fn get_as(_name: &str, _switch_val: Option<&str>) -> Result + where + T: TryFrom, + >::Error: std::error::Error + Send + Sync + 'static, + { + Ok(0.try_into()?) + } +}