Struct PacScriptCacheLayer
pub struct PacScriptCacheLayer { /* private fields */ }js and pac and std only.Expand description
Keeps a fetched script for ttl,
so an always-fetching provider does not hit the network per request.
At most one refresh per script URI runs at a time, however many callers arrive. A slow obsolete URI therefore cannot block a newly configured URI. A caller with a usable script gets it right away; callers for the same URI share the outcome of the attempt already in flight.
Implementations§
§impl PacScriptCacheLayer
impl PacScriptCacheLayer
pub const DEFAULT_TTL: Duration
pub const DEFAULT_TTL: Duration
How long a fetched script is reused by default.
Browsers hold a pac file for hours; a script uri change bypasses the ttl anyway, so a long default costs little.
pub const REFRESH_BACKOFF: Duration
pub const REFRESH_BACKOFF: Duration
How long a failed refresh is remembered before the origin is tried again.
Within the window a stale script is served straight away — and the
refresh error returned right away when
serve_stale is off — so an unreachable
origin costs one attempt per window instead of one per caller.
pub fn new() -> PacScriptCacheLayer
pub fn new() -> PacScriptCacheLayer
Create a new PacScriptCacheLayer.
pub fn with_ttl(self, ttl: Duration) -> PacScriptCacheLayer
pub fn with_ttl(self, ttl: Duration) -> PacScriptCacheLayer
Reuse a fetched script for this long
(defaults to Self::DEFAULT_TTL).
pub fn set_ttl(&mut self, ttl: Duration) -> &mut PacScriptCacheLayer
pub fn set_ttl(&mut self, ttl: Duration) -> &mut PacScriptCacheLayer
Reuse a fetched script for this long
(defaults to Self::DEFAULT_TTL).
pub fn with_serve_stale(self, serve_stale: bool) -> PacScriptCacheLayer
pub fn with_serve_stale(self, serve_stale: bool) -> PacScriptCacheLayer
Keep serving an expired script when the refresh fails
(defaults to true: a stale policy beats no policy).
Either way a failed refresh opens a Self::REFRESH_BACKOFF
window in which the origin is left alone.
pub fn set_serve_stale(&mut self, serve_stale: bool) -> &mut PacScriptCacheLayer
pub fn set_serve_stale(&mut self, serve_stale: bool) -> &mut PacScriptCacheLayer
Keep serving an expired script when the refresh fails
(defaults to true: a stale policy beats no policy).
Either way a failed refresh opens a Self::REFRESH_BACKOFF
window in which the origin is left alone.
Trait Implementations§
§impl Clone for PacScriptCacheLayer
impl Clone for PacScriptCacheLayer
§fn clone(&self) -> PacScriptCacheLayer
fn clone(&self) -> PacScriptCacheLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for PacScriptCacheLayer
impl Debug for PacScriptCacheLayer
§impl Default for PacScriptCacheLayer
impl Default for PacScriptCacheLayer
§fn default() -> PacScriptCacheLayer
fn default() -> PacScriptCacheLayer
§impl<S> Layer<S> for PacScriptCacheLayer
impl<S> Layer<S> for PacScriptCacheLayer
§type Service = PacScriptCache<S>
type Service = PacScriptCache<S>
§fn layer(&self, inner: S) -> <PacScriptCacheLayer as Layer<S>>::Service
fn layer(&self, inner: S) -> <PacScriptCacheLayer as Layer<S>>::Service
§fn into_layer(self, inner: S) -> Self::Service
fn into_layer(self, inner: S) -> Self::Service
layer but consuming self after the service was created. Read moreAuto Trait Implementations§
impl Freeze for PacScriptCacheLayer
impl RefUnwindSafe for PacScriptCacheLayer
impl Send for PacScriptCacheLayer
impl Sync for PacScriptCacheLayer
impl Unpin for PacScriptCacheLayer
impl UnsafeUnpin for PacScriptCacheLayer
impl UnwindSafe for PacScriptCacheLayer
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<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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more