Struct PacResolver
pub struct PacResolver { /* private fields */ }js and pac and std only.Expand description
Evaluates a PAC script to decide how a request should be proxied.
The script comes from a provider on every lookup, and the worker is only rebuilt when the script actually changed — so an always-fetching provider stays affordable and a swapped script takes effect at once.
Implementations§
§impl PacResolver
impl PacResolver
pub fn builder() -> PacResolverBuilder
pub fn builder() -> PacResolverBuilder
Create a PacResolverBuilder.
pub async fn find_proxy(
&self,
uri: &Uri,
) -> Result<PacDirectives, Box<dyn Error + Send + Sync>>
pub async fn find_proxy( &self, uri: &Uri, ) -> Result<PacDirectives, Box<dyn Error + Send + Sync>>
The proxies to try for uri, in the order the script named them.
The script is fetched from the provider, compiled once, and evaluated per call; it is recompiled only when the provider serves different bytes. What the script may spend while answering is bounded — see the crate docs.
§impl PacResolver
impl PacResolver
pub const DEFAULT_EXECUTION_TIME_LIMIT: Duration
pub const DEFAULT_EXECUTION_TIME_LIMIT: Duration
Wall-clock limit one FindProxyForURL call gets by default.
pub const MAX_WORKER_SPAWNS_PER_WINDOW: usize = 3
pub const MAX_WORKER_SPAWNS_PER_WINDOW: usize = 3
How many js workers may remain at risk within a cooldown window before the resolver stops building them.
A script can wedge its worker in native code no javascript limit can interrupt, which leaks that worker’s thread. Loads and calls remain charged until the worker thread proves they returned; completed work costs nothing. Charges age out of the window on their own, so a script is never written off permanently.
pub const DEFAULT_WEDGE_COOLDOWN: Duration
pub const DEFAULT_WEDGE_COOLDOWN: Duration
How long an unresolved worker charge counts against
MAX_WORKER_SPAWNS_PER_WINDOW
by default.
pub const fn default_timeout_for(limit: Duration) -> Duration
pub const fn default_timeout_for(limit: Duration) -> Duration
The lookup timeout derived from limit when none was configured:
strictly greater than the execution time limit, so a bounded
runaway is still reported as such, with room for queue time.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PacResolver
impl !RefUnwindSafe for PacResolver
impl !UnwindSafe for PacResolver
impl Send for PacResolver
impl Sync for PacResolver
impl Unpin for PacResolver
impl UnsafeUnpin for PacResolver
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
§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