Skip to content

Commit

Permalink
Add HashedTokenRouter back as alias for TokenRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed Sep 18, 2024
1 parent 3363452 commit 5047473
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/filters/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl FilterSet {
filters::Debug::factory(),
filters::Drop::factory(),
filters::Firewall::factory(),
filters::HashedTokenRouter::factory(),
filters::LoadBalancer::factory(),
filters::LocalRateLimit::factory(),
filters::Match::factory(),
Expand Down
21 changes: 21 additions & 0 deletions src/filters/token_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ impl Filter for TokenRouter {
}
}

struct HashedTokenRouter(TokenRouter);

impl StaticFilter for HashedTokenRouter {
const NAME: &'static str = "quilkin.filters.token_router.v1alpha1.HashedTokenRouter";
type Configuration = Config;
type BinaryConfiguration = proto::TokenRouter;

fn try_from_config(config: Option<Self::Configuration>) -> Result<Self, CreationError> {
Ok(Self(TokenRouter {
config: config.unwrap_or_default(),
}))
}
}

#[async_trait::async_trait]
impl Filter for HashedTokenRouter {
async fn read(&self, ctx: &mut ReadContext) -> Result<(), FilterError> {
self.0.sync_read(ctx)
}
}

pub enum RouterError {
NoTokenFound,
NoEndpointMatch { token: bytes::Bytes },
Expand Down
3 changes: 0 additions & 3 deletions src/xds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ impl Resource {
}
};

let len = config.value.len();

let json_value = match crate::filters::FilterRegistry::get_factory(&filter.name)
.ok_or_else(|| {
crate::filters::CreationError::NotFound(filter.name.clone())
Expand All @@ -88,7 +86,6 @@ impl Resource {
{
Ok(jv) => jv,
Err(err) => {
tracing::error!("wtf {} {len} {err:#}", filter.name);
return Err(err.into());
}
};
Expand Down

0 comments on commit 5047473

Please sign in to comment.