Struct MemoryProxyDB
pub struct MemoryProxyDB { /* private fields */ }proxy only.Expand description
A fast in-memory ProxyDatabase that is the default choice for Rama.
Plural queries return a uniformly shuffled sample up to the requested limit, or every match when unbounded. Singular queries pick a random match without collecting the others first.
Proxies can be flagged while the database is in use, e.g. to stop
selecting a proxy that is blocked or unhealthy, through the
ProxyRuntimeColumns created with MemoryProxyDB::new_exclude_column
and MemoryProxyDB::new_require_column.
Implementations§
§impl MemoryProxyDB
impl MemoryProxyDB
pub fn new_exclude_column(&mut self) -> ProxyRuntimeColumn
pub fn new_exclude_column(&mut self) -> ProxyRuntimeColumn
Create a column of proxies that this database never selects, starting out empty.
Insert a proxy in it to stop selecting it, e.g. once it is found
to be blocked or unhealthy, and remove it to select it again.
The column can be changed at any time and from any task,
also after the database is handed to a ProxyDBLayer.
pub fn new_require_column(&mut self) -> ProxyRuntimeColumn
pub fn new_require_column(&mut self) -> ProxyRuntimeColumn
Create a column of proxies that this database is limited to, starting out empty.
Only the proxies inserted in it can be selected: as long as it is empty
no proxy is. The column can be changed at any time and from any task,
also after the database is handed to a ProxyDBLayer.
pub fn try_from_rows(
proxies: Vec<Proxy>,
) -> Result<MemoryProxyDB, MemoryProxyDBInsertError>
pub fn try_from_rows( proxies: Vec<Proxy>, ) -> Result<MemoryProxyDB, MemoryProxyDBInsertError>
Create a new in-memory proxy database with the given proxies.
pub fn try_from_iter<I>(
proxies: I,
) -> Result<MemoryProxyDB, MemoryProxyDBInsertError>where
I: IntoIterator<Item = Proxy>,
pub fn try_from_iter<I>(
proxies: I,
) -> Result<MemoryProxyDB, MemoryProxyDBInsertError>where
I: IntoIterator<Item = Proxy>,
Create a new in-memory proxy database with the given proxies from an iterator.
Trait Implementations§
§impl Debug for MemoryProxyDB
impl Debug for MemoryProxyDB
§impl ProxyDB for MemoryProxyDB
impl ProxyDB for MemoryProxyDB
§type Error = MemoryProxyDBQueryError
type Error = MemoryProxyDBQueryError
§async fn get_proxies_if(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
predicate: impl ProxyQueryPredicate,
limit: Option<NonZero<usize>>,
) -> Result<NonEmptyVec<Proxy>, <MemoryProxyDB as ProxyDB>::Error>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZero<usize>>, ) -> Result<NonEmptyVec<Proxy>, <MemoryProxyDB as ProxyDB>::Error>
Proxy values in database-defined preference order,
after applying an additional predicate and optional result limit.§async fn get_proxy_if(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
predicate: impl ProxyQueryPredicate,
) -> Result<Proxy, <MemoryProxyDB as ProxyDB>::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, <MemoryProxyDB as ProxyDB>::Error>
§fn get_proxies(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
limit: Option<NonZero<usize>>,
) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send
fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZero<usize>>, ) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send
Proxy values in database-defined preference order,
up to the optional result limit.§fn get_proxy(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
) -> impl Future<Output = Result<Proxy, Self::Error>> + Send
fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> impl Future<Output = Result<Proxy, Self::Error>> + Send
Proxy based on the given ProxyContext and ProxyFilter,
or return an error in case no Proxy could be returned.Auto Trait Implementations§
impl Forget for MemoryProxyDB
impl Freeze for MemoryProxyDB
impl Move for MemoryProxyDB
impl RefUnwindSafe for MemoryProxyDB
impl Send for MemoryProxyDB
impl Sync for MemoryProxyDB
impl Unpin for MemoryProxyDB
impl UnsafeUnpin for MemoryProxyDB
impl UnwindSafe for MemoryProxyDB
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