pub struct HotRuleEngine { /* private fields */ }Expand description
A hot-reloadable wrapper around RuleEngine.
Uses ArcSwap for lock-free reads and atomic replacement.
All reads go through arc_swap::Guard which is wait-free.
Implementations§
Source§impl HotRuleEngine
impl HotRuleEngine
Sourcepub fn new(engine: RuleEngine) -> Self
pub fn new(engine: RuleEngine) -> Self
Create a new hot-reloadable engine with the given initial engine.
Sourcepub fn match_request(&self, ctx: &MatchContext<'_>) -> Action
pub fn match_request(&self, ctx: &MatchContext<'_>) -> Action
Match a request against the current rules.
Returns an owned Action (cloned from the engine) so the caller
does not hold a borrow on the engine across await points.
Sourcepub fn has_ip_rules(&self) -> bool
pub fn has_ip_rules(&self) -> bool
Returns true if the current engine has IP-based rules.
Sourcepub fn update(&self, engine: RuleEngine)
pub fn update(&self, engine: RuleEngine)
Atomically replace the engine with a new one.
Sourcepub fn match_request_lazy_ip(&self, ctx: &MatchContext<'_>) -> Option<Action>
pub fn match_request_lazy_ip(&self, ctx: &MatchContext<'_>) -> Option<Action>
Lazy IP matching: returns Some(action) if a rule matched without DNS,
None if an IP-based rule appeared first and DNS resolution is needed.
The caller should resolve DNS and then call match_request() with the
resolved IP when None is returned.
Sourcepub fn rule_set_count(&self) -> usize
pub fn rule_set_count(&self) -> usize
Number of compiled rule-sets in the current engine.
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Number of engine rules in the current engine.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HotRuleEngine
impl RefUnwindSafe for HotRuleEngine
impl Send for HotRuleEngine
impl Sync for HotRuleEngine
impl Unpin for HotRuleEngine
impl UnsafeUnpin for HotRuleEngine
impl UnwindSafe for HotRuleEngine
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
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> 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