Skip to content

Commit

Permalink
add justknobs stub
Browse files Browse the repository at this point in the history
Reviewed By: mitrandir77, RajivTS

Differential Revision: D50264249

fbshipit-source-id: 56d624c97fcde323e3f7525349052ef3e41b11f7
  • Loading branch information
markbt authored and facebook-github-bot committed Oct 13, 2023
1 parent e817b10 commit e1ab0bd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions shed/justknobs_stub/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @generated by autocargo

[package]
name = "justknobs"
version = "0.1.0"
authors = ["Facebook <[email protected]>"]
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"
38 changes: 38 additions & 0 deletions shed/justknobs_stub/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<bool> {
Ok(false)
}

pub fn get(_name: &str, _switch_val: Option<&str>) -> Result<i64> {
Ok(0)
}

pub fn get_as<T>(_name: &str, _switch_val: Option<&str>) -> Result<T>
where
T: TryFrom<i64>,
<T as TryFrom<i64>>::Error: std::error::Error + Send + Sync + 'static,
{
Ok(0.try_into()?)
}
}

0 comments on commit e1ab0bd

Please sign in to comment.