pub struct PolicyResolver { /* private fields */ }Expand description
Shared resolve-with-cache helper for fleet policy gates.
Each subject (per project root) resolves over its own route, which also
carries a policy.subscribe task. State for a subject is released once its
verdicts expire: expired entries are removed, and a route whose last verdict
has expired, with no resolve in flight on it, is closed and its subscription
task aborted. That happens in a sweep at the start of resolve, which runs
only once the earliest recorded expiry has passed, so a resolver holds state
only for subjects with a verdict still live, plus at most whatever expired
since its last call. Expiry was chosen over an LRU cap because TTL is what
already bounds a verdict’s usefulness, and a cap would either close routes
with live verdicts or need a size nobody can pick for every deployment.
Implementations§
Source§impl PolicyResolver
impl PolicyResolver
Sourcepub fn new(consumer: SubcConsumer, config: PolicyResolverConfig) -> Self
pub fn new(consumer: SubcConsumer, config: PolicyResolverConfig) -> Self
Create a resolver that targets DEFAULT_POLICY_RESOLVER_MODULE_ID.
Sourcepub fn with_resolver_target(
consumer: SubcConsumer,
resolver_module_id: impl Into<String>,
config: PolicyResolverConfig,
) -> Self
pub fn with_resolver_target( consumer: SubcConsumer, resolver_module_id: impl Into<String>, config: PolicyResolverConfig, ) -> Self
Create a resolver that targets a deployment-specific policy module.
Sourcepub async fn resolve(
&self,
domain: &str,
gate_id: &str,
subject: Subject,
project: ProjectRef,
) -> Result<PolicyVerdict, PolicyResolveError>
pub async fn resolve( &self, domain: &str, gate_id: &str, subject: Subject, project: ProjectRef, ) -> Result<PolicyVerdict, PolicyResolveError>
Resolve one gate, using a revision-validated cache entry only while its TTL remains live.
Sourcepub fn footprint(&self) -> PolicyResolverFootprint
pub fn footprint(&self) -> PolicyResolverFootprint
How much per-subject state this resolver holds right now.