From bdd68bb0699a88dc7a5ce9d2ef89d2cd724366ec Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Thu, 27 Mar 2025 12:39:00 +0100 Subject: [PATCH] bump --- Cargo.lock | 4 +- proxy/Cargo.toml | 2 +- proxy/src/auth/backend/console_redirect.rs | 2 +- proxy/src/auth/backend/jwt.rs | 2 +- proxy/src/auth/backend/local.rs | 6 +-- proxy/src/cache/project_info.rs | 8 ++-- proxy/src/context/mod.rs | 2 +- proxy/src/intern.rs | 54 +++++----------------- proxy/src/types.rs | 2 +- 9 files changed, 25 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0942f4b481..152f934060 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4614,9 +4614,9 @@ dependencies = [ [[package]] name = "paracord" -version = "0.1.0-rc.5" +version = "0.1.0-rc.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4d20c42ae2826a91463e015d3d76064b07b222d94d3646e854071aae25043b" +checksum = "965ee8b44c8a2556aa73279eab88d5aa63a2859336d8a61295104c8d8a4fb248" dependencies = [ "boxcar", "clashmap", diff --git a/proxy/Cargo.toml b/proxy/Cargo.toml index 149accc44a..8bfcecc311 100644 --- a/proxy/Cargo.toml +++ b/proxy/Cargo.toml @@ -114,7 +114,7 @@ ed25519-dalek = { version = "2", default-features = false, features = ["rand_cor rsa = "0.9" workspace_hack.workspace = true -paracord = { version = "0.1.0-rc.5", features = ["serde"] } +paracord = { version = "0.1.0-rc.6", features = ["serde"] } [dev-dependencies] assert-json-diff.workspace = true diff --git a/proxy/src/auth/backend/console_redirect.rs b/proxy/src/auth/backend/console_redirect.rs index e890f1de1a..f561df9202 100644 --- a/proxy/src/auth/backend/console_redirect.rs +++ b/proxy/src/auth/backend/console_redirect.rs @@ -203,7 +203,7 @@ async fn authenticate( let user: RoleName = db_info.user.into(); let user_info = ComputeUserInfo { - endpoint: db_info.aux.endpoint_id.resolve().into(), + endpoint: db_info.aux.endpoint_id.as_str().into(), user: user.clone(), options: NeonOptions::default(), }; diff --git a/proxy/src/auth/backend/jwt.rs b/proxy/src/auth/backend/jwt.rs index 4fa51f0611..4f8da2c34b 100644 --- a/proxy/src/auth/backend/jwt.rs +++ b/proxy/src/auth/backend/jwt.rs @@ -87,7 +87,7 @@ impl JwkCacheEntry { self.key_sets .values() // make sure our requested role has access to the key set - .filter(|key_set| key_set.role_names.iter().any(|role| *role.resolve() == **role_name)) + .filter(|key_set| key_set.role_names.iter().any(|role| *role.as_str() == **role_name)) // try and find the requested key-id in the key set .find_map(|key_set| { key_set diff --git a/proxy/src/auth/backend/local.rs b/proxy/src/auth/backend/local.rs index 7081904405..bc2f375ab3 100644 --- a/proxy/src/auth/backend/local.rs +++ b/proxy/src/auth/backend/local.rs @@ -38,9 +38,9 @@ impl LocalBackend { }, // TODO(conrad): make this better reflect compute info rather than endpoint info. aux: MetricsAuxInfo { - endpoint_id: EndpointIdInt::get_or_intern("local"), - project_id: ProjectIdInt::get_or_intern("local"), - branch_id: BranchIdInt::get_or_intern("local"), + endpoint_id: EndpointIdInt::from_str_or_intern("local"), + project_id: ProjectIdInt::from_str_or_intern("local"), + branch_id: BranchIdInt::from_str_or_intern("local"), compute_id: "local".into(), cold_start_info: ColdStartInfo::WarmCached, }, diff --git a/proxy/src/cache/project_info.rs b/proxy/src/cache/project_info.rs index d37c107323..1e5451e370 100644 --- a/proxy/src/cache/project_info.rs +++ b/proxy/src/cache/project_info.rs @@ -194,7 +194,7 @@ impl ProjectInfoCacheImpl { &self, endpoint_id: &EndpointId, ) -> Option> { - let endpoint_id = EndpointIdInt::get(endpoint_id)?; + let endpoint_id = EndpointIdInt::try_from_str(endpoint_id)?; self.cache.get(&endpoint_id) } @@ -204,7 +204,7 @@ impl ProjectInfoCacheImpl { role_name: &RoleName, ) -> Option { let valid_since = self.get_cache_times(); - let role_name = RoleNameInt::get(role_name)?; + let role_name = RoleNameInt::try_from_str(role_name)?; let endpoint_info = self.get_endpoint_cache(endpoint_id)?; endpoint_info.get_role_secret(role_name, valid_since) } @@ -297,10 +297,10 @@ impl ProjectInfoCacheImpl { } pub fn maybe_invalidate_role_secret(&self, endpoint_id: &EndpointId, role_name: &RoleName) { - let Some(endpoint_id) = EndpointIdInt::get(endpoint_id) else { + let Some(endpoint_id) = EndpointIdInt::try_from_str(endpoint_id) else { return; }; - let Some(role_name) = RoleNameInt::get(role_name) else { + let Some(role_name) = RoleNameInt::try_from_str(role_name) else { return; }; diff --git a/proxy/src/context/mod.rs b/proxy/src/context/mod.rs index 13b2066c19..3a8828e70c 100644 --- a/proxy/src/context/mod.rs +++ b/proxy/src/context/mod.rs @@ -210,7 +210,7 @@ impl RequestContext { pub(crate) fn set_project(&self, x: MetricsAuxInfo) { let mut this = self.0.try_lock().expect("should not deadlock"); if this.endpoint_id.is_none() { - this.set_endpoint_id(x.endpoint_id.resolve().into()); + this.set_endpoint_id(x.endpoint_id.as_str().into()); } this.branch = Some(x.branch_id); this.project = Some(x.project_id); diff --git a/proxy/src/intern.rs b/proxy/src/intern.rs index 9016fb420a..bddfa87d3a 100644 --- a/proxy/src/intern.rs +++ b/proxy/src/intern.rs @@ -1,5 +1,3 @@ -use core::fmt; - use paracord::custom_key; use crate::types::{AccountId, BranchId, EndpointId, ProjectId, RoleName}; @@ -12,92 +10,62 @@ custom_key!(pub struct AccountIdInt); impl From<&RoleName> for RoleNameInt { fn from(value: &RoleName) -> Self { - RoleNameInt::get_or_intern(value) - } -} -impl fmt::Display for RoleNameInt { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(self.resolve()) + RoleNameInt::from_str_or_intern(value) } } impl From<&EndpointId> for EndpointIdInt { fn from(value: &EndpointId) -> Self { - EndpointIdInt::get_or_intern(value) + EndpointIdInt::from_str_or_intern(value) } } impl From for EndpointIdInt { fn from(value: EndpointId) -> Self { - EndpointIdInt::get_or_intern(&value) - } -} -impl fmt::Display for EndpointIdInt { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(self.resolve()) + EndpointIdInt::from_str_or_intern(&value) } } impl From<&BranchId> for BranchIdInt { fn from(value: &BranchId) -> Self { - BranchIdInt::get_or_intern(value) + BranchIdInt::from_str_or_intern(value) } } impl From for BranchIdInt { fn from(value: BranchId) -> Self { - BranchIdInt::get_or_intern(&value) - } -} -impl AsRef for BranchIdInt { - fn as_ref(&self) -> &str { - self.resolve() + BranchIdInt::from_str_or_intern(&value) } } impl std::ops::Deref for BranchIdInt { type Target = str; fn deref(&self) -> &str { - self.resolve() + self.as_str() } } impl From<&ProjectId> for ProjectIdInt { fn from(value: &ProjectId) -> Self { - ProjectIdInt::get_or_intern(value) + ProjectIdInt::from_str_or_intern(value) } } impl From for ProjectIdInt { fn from(value: ProjectId) -> Self { - ProjectIdInt::get_or_intern(&value) - } -} -impl AsRef for ProjectIdInt { - fn as_ref(&self) -> &str { - self.resolve() + ProjectIdInt::from_str_or_intern(&value) } } impl std::ops::Deref for ProjectIdInt { type Target = str; fn deref(&self) -> &str { - self.resolve() - } -} -impl fmt::Display for ProjectIdInt { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(self.resolve()) + self.as_str() } } impl From<&AccountId> for AccountIdInt { fn from(value: &AccountId) -> Self { - AccountIdInt::get_or_intern(value) + AccountIdInt::from_str_or_intern(value) } } impl From for AccountIdInt { fn from(value: AccountId) -> Self { - AccountIdInt::get_or_intern(&value) - } -} -impl fmt::Display for AccountIdInt { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(self.resolve()) + AccountIdInt::from_str_or_intern(&value) } } diff --git a/proxy/src/types.rs b/proxy/src/types.rs index e97139d847..c14b493227 100644 --- a/proxy/src/types.rs +++ b/proxy/src/types.rs @@ -85,7 +85,7 @@ impl EndpointId { #[must_use] pub fn normalize_intern(&self) -> EndpointIdInt { - EndpointIdInt::get_or_intern(self.normalize_str()) + EndpointIdInt::from_str_or_intern(self.normalize_str()) } }