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.