pub struct ProxyLimits {
settings: ProxySettings,
rate: DefaultKeyedRateLimiter<String>,
last_swept: Mutex<Instant>,
open: Arc<Mutex<Open>>,
targets: Mutex<LruCache<String, Endpoint>>,
}Expand description
The per-account bounds on proxied calls, and the cache of targets’ endpoints, for one deployment.
Fields§
§settings: ProxySettings§rate: DefaultKeyedRateLimiter<String>§last_swept: Mutex<Instant>§open: Arc<Mutex<Open>>§targets: Mutex<LruCache<String, Endpoint>>Implementations§
Source§impl ProxyLimits
impl ProxyLimits
Sourcepub fn new(settings: ProxySettings) -> Self
pub fn new(settings: ProxySettings) -> Self
Bounds set by settings. A zero anywhere counts as one.
Sourcepub fn settings(&self) -> &ProxySettings
pub fn settings(&self) -> &ProxySettings
The settings these bounds were built from.
Sourcepub(crate) fn admit(&self, did: &str, tree: &str) -> Result<InFlight, Refusal>
pub(crate) fn admit(&self, did: &str, tree: &str) -> Result<InFlight, Refusal>
Spends one of did’s calls and holds it open, or says why not.
tree names the account tree did is in; see
ProxySettings::in_flight_per_tree.
The rate is checked first, so a call refused for being in flight has still spent its place in the budget: an account retrying against its own stalled calls slows itself down.
Sourcepub(crate) fn cached_target(
&self,
target: &str,
private: PrivateAddresses,
) -> Option<Url>
pub(crate) fn cached_target( &self, target: &str, private: PrivateAddresses, ) -> Option<Url>
The endpoint cached for target, if one is fresh and was found
under private.
Sourcepub(crate) fn cache_target(
&self,
target: &str,
private: PrivateAddresses,
url: &Url,
)
pub(crate) fn cache_target( &self, target: &str, private: PrivateAddresses, url: &Url, )
Keeps the endpoint target’s document named, found under private.
Sourcefn sweep(&self)
fn sweep(&self)
Drops full buckets, at most once per SWEEP_EVERY, so the rate
map holds the accounts calling now rather than every account that
ever has.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProxyLimits
impl !RefUnwindSafe for ProxyLimits
impl Send for ProxyLimits
impl Sync for ProxyLimits
impl Unpin for ProxyLimits
impl UnsafeUnpin for ProxyLimits
impl UnwindSafe for ProxyLimits
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more