Skip to main content

FilterPlugin

Trait FilterPlugin 

Source
pub trait FilterPlugin: Send + Sync {
    // Required methods
    fn filter(
        &self,
        ctx: &RequestContext,
        principal: &Principal,
        candidates: &[UpstreamCandidate],
    ) -> Result<FilterOutput, FilterError>;
    fn plugin_id(&self) -> Uuid;
    fn plugin_name(&self) -> &str;

    // Provided method
    fn slot_key(&self) -> SlotKey { ... }
}
Expand description

Filter plugin boundary for upstream candidate filtering and decision-making.

Filter plugins evaluate requests against custom criteria and decide which upstream candidates are acceptable. They have access to the request context, authenticated principal, and list of available upstream candidates, and return a filtered set of acceptable upstreams along with per-candidate reasoning.

Required Methods§

Source

fn filter( &self, ctx: &RequestContext, principal: &Principal, candidates: &[UpstreamCandidate], ) -> Result<FilterOutput, FilterError>

Filters upstream candidates based on request and principal.

Returns a FilterOutput containing the kept upstream IDs and per-candidate reasons, or a FilterError if filtering fails.

Source

fn plugin_id(&self) -> Uuid

Returns the stable plugin identifier.

Source

fn plugin_name(&self) -> &str

Returns the human-readable plugin name.

Provided Methods§

Source

fn slot_key(&self) -> SlotKey

Returns the composite key identifying this filter slot — the principal it is bound to and the plugin name. Callers use this to address cache eviction, hot reload, and per-slot metrics uniformly across runtime implementations.

The default impl returns a global slot key derived from Self::plugin_name. Runtime impls bound to a specific principal (e.g. wasmtime) override this to return the principal × plugin pair they were instantiated with.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§