Skip to content

Commit

Permalink
Remove single identity target type
Browse files Browse the repository at this point in the history
Summary:
This diff is refctoring target structs. Specifically:
- And, or and Not are deprecated
Instead:
- Rules can be specified severla times to cover Or cases
- A list of identities replaces And
- Single identities can be expressed as a list of identities with a single item
- Static slices now must contain a target that it applies to. Beforehand it required And

Reviewed By: mitrandir77

Differential Revision: D65667107

fbshipit-source-id: a361a680b9400f51448f22986713f53bbbc952be
  • Loading branch information
Clara Rull authored and facebook-github-bot committed Nov 14, 2024
1 parent 7554f79 commit e56ed9b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
3 changes: 0 additions & 3 deletions eden/mononoke/rate_limiting/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ impl TryFrom<rate_limiting_config::Target> for Target {

fn try_from(value: rate_limiting_config::Target) -> Result<Self, Self::Error> {
match value {
rate_limiting_config::Target::identity(i) => {
Ok(Target::Identity(FromStr::from_str(&i)?))
}
rate_limiting_config::Target::static_slice(s) => {
let slice_pct = s.slice_pct.try_into()?;
Ok(Target::StaticSlice(StaticSlice {
Expand Down
7 changes: 1 addition & 6 deletions eden/mononoke/rate_limiting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use anyhow::Error;
use async_trait::async_trait;
use cached_config::ConfigHandle;
use fbinit::FacebookInit;
use permission_checker::MononokeIdentity;
use permission_checker::MononokeIdentitySet;
use permission_checker::MononokeIdentitySetExt;
use scuba_ext::MononokeScubaSampleBuilder;
Expand Down Expand Up @@ -243,7 +242,6 @@ pub enum RateLimitReason {

#[derive(Debug, Clone)]
pub enum Target {
Identity(MononokeIdentity),
StaticSlice(StaticSlice),
MainClientId(String),
Identities(MononokeIdentitySet),
Expand Down Expand Up @@ -295,10 +293,6 @@ impl Target {
None => false,
}
}
Self::Identity(i) => match identities {
Some(client_idents) => client_idents.contains(i),
None => false,
},
Self::MainClientId(id) => match main_client_id {
Some(client_id) => client_id == id,
None => false,
Expand Down Expand Up @@ -357,6 +351,7 @@ fn in_throttled_slice(
#[cfg(test)]
mod test {
use mononoke_macros::mononoke;
use permission_checker::MononokeIdentity;

use super::*;

Expand Down

0 comments on commit e56ed9b

Please sign in to comment.