#[non_exhaustive]pub struct ShieldConfig {
pub enabled: bool,
pub profiles: HashMap<String, LimitProfileConfig>,
pub rules: Vec<RateRuleConfig>,
pub default_profile: Option<String>,
pub jwt_limits: Option<JwtLimitConfig>,
pub limit_service: Option<LimitServiceConfig>,
pub sync: Option<SyncConfig>,
pub trusted_proxies: Vec<String>,
}Expand description
Shield (rate limiting) configuration.
The proxy runs embedded on each service instance, so every limit decision is
made locally with a GCRA shaper (zero blocking latency). A shared store, when
configured via sync, is reconciled asynchronously off
the request path to approximate a fleet-wide limit; the request path never
blocks on it.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.enabled: bool§profiles: HashMap<String, LimitProfileConfig>Named limit tiers referenced by rules and by tier-name resolution (JWT
claim / limit service). Map of profile name → { rate, burst }.
rules: Vec<RateRuleConfig>Rate-limit rules, evaluated in order; the first whose pattern matches the request path applies.
default_profile: Option<String>Profile name applied when a matched rule resolves no other limit (JWT and
service resolution absent or empty, and the rule sets no explicit
profile). Must name an entry in profiles.
jwt_limits: Option<JwtLimitConfig>Resolve a key’s limit from claims in the validated JWT. Presence enables JWT-based resolution (tier name or explicit numbers).
limit_service: Option<LimitServiceConfig>Resolve a key’s limit from an external service. The lookup is cached and refreshed in the background; the request path never blocks on it.
sync: Option<SyncConfig>Asynchronous cross-instance reconciliation via a shared store. When unset, each instance limits locally (fleet limit ≈ N × per-instance).
trusted_proxies: Vec<String>CIDR ranges of trusted reverse proxies / load balancers (e.g.
“10.0.0.0/8”). X-Forwarded-For / X-Real-IP are honored only when the
direct peer falls in one of these ranges; otherwise the peer socket
address is used as the client identity. Empty (the default) means do not
trust forwarding headers; set this behind a load balancer.
Trait Implementations§
Source§impl Clone for ShieldConfig
impl Clone for ShieldConfig
Source§fn clone(&self) -> ShieldConfig
fn clone(&self) -> ShieldConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShieldConfig
impl Debug for ShieldConfig
Source§impl<'de> Deserialize<'de> for ShieldConfig
impl<'de> Deserialize<'de> for ShieldConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ShieldConfig
impl RefUnwindSafe for ShieldConfig
impl Send for ShieldConfig
impl Sync for ShieldConfig
impl Unpin for ShieldConfig
impl UnsafeUnpin for ShieldConfig
impl UnwindSafe for ShieldConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request