Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn plugin_type(&self) -> &str;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        ctx: Context,
    ) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn reads_response_body(&self) -> bool { ... }
    fn cache_target(&self) -> Option<CacheTarget> { ... }
}
Expand description

Every plugin (native or scripted) implements this trait.

A plugin is a node in a compiled policy graph. The engine drives each node through execute and follows the output port the result names.

A node type’s ports are not declared on this trait: they live in the static registry (port_spec over ports), the single source of truth shared by the graph compiler, the admin catalog, and the UI editor. A plugin therefore cannot drift from its own declaration.

Required Methods§

Source

fn plugin_type(&self) -> &str

Unique identifier for the plugin type (e.g., “proxy-rewrite”, “upstream”). This is also the key its PortSpec is registered under in port_spec.

Source

fn execute<'life0, 'async_trait>( &'life0 self, ctx: Context, ) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Executes the plugin logic against the request/response context.

Contract:

  • ctx is taken by value: the plugin owns the Context for the duration of the call and must hand it back in either outcome — inside PluginOutput on success, or inside PluginExecutionError on failure. The context is never lost.
  • On Ok, the engine routes the returned context through the port the PluginOutput names: PluginOutput::success takes the node’s success port, and PluginOutput::on_port takes a named outcome port — the node did its job and chose a deliberate alternate route (denied, redirect, limited, broken, preflight, abort, routed, hit, respond, true/false), normally with the client-facing response already prepared. The named port must be one this type declares in its PortSpec, or the policy would not have compiled; nothing is appended to ctx.errors.
  • On Err, the PluginExecutionError carries both the context and a GatewayError, which the engine appends to ctx.errors before continuing through the node’s error port (or the policy catch-all, or a generic 500) instead of aborting the request. Err is reserved for the node could not do its job — configuration, parse, or infrastructure failure. A plugin must never name error from Ok.

Provided Methods§

Source

fn reads_response_body(&self) -> bool

Whether this configured instance reads context.response.body.

Defaults to true: a plugin that does not opt out forces the policy to buffer, so adding a plugin can never silently break a stream. Opting out is a deliberate statement about a specific configuration. Consulted at policy-compile time by infer_stream_capability (src/graph/engine.rs), which walks an upstream node’s success path and only marks it stream-capable when every node on that path opts out.

Source

fn cache_target(&self) -> Option<CacheTarget>

The cache backend this node writes to, if it is a proxy-cache half.

Consulted at policy-compile time so an invalidation request can find every backend that holds entries for a pair id – the same shape as reads_response_body: the node describes itself, the compiler collects the answers, and there is no process-wide registry that would have to survive hot-reloads.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Plugin for AclPlugin

Source§

impl Plugin for ApiBreakerPlugin

Source§

impl Plugin for AttachConsumerLabelPlugin

Source§

impl Plugin for AuthzCasbinPlugin

Source§

impl Plugin for AuthzCasdoorPlugin

Source§

impl Plugin for AuthzKeycloakPlugin

Source§

impl Plugin for AwsLambdaPlugin

Source§

impl Plugin for AzureFunctionsPlugin

Source§

impl Plugin for BasicAuthPlugin

Source§

impl Plugin for BodyTransformerPlugin

Source§

impl Plugin for BrotliPlugin

Source§

impl Plugin for CasAuthPlugin

Source§

impl Plugin for ClickhouseLoggerPlugin

Source§

impl Plugin for ClientPlugin

Source§

impl Plugin for ConditionPlugin

Source§

impl Plugin for ConsumerRestrictionPlugin

Source§

impl Plugin for CorsPlugin

Source§

impl Plugin for CsrfPlugin

Source§

impl Plugin for DataMaskPlugin

Source§

impl Plugin for DatadogPlugin

Source§

impl Plugin for DegraphqlPlugin

Source§

impl Plugin for DingtalkAuthPlugin

Source§

impl Plugin for EchoPlugin

Source§

impl Plugin for ElasticsearchLoggerPlugin

Source§

impl Plugin for ErrorHandlerPlugin

Source§

impl Plugin for ErrorLogLoggerPlugin

Source§

impl Plugin for ErrorPagePlugin

Source§

impl Plugin for ExitTransformerPlugin

Source§

impl Plugin for FaultInjectionPlugin

Source§

impl Plugin for FeishuAuthPlugin

Source§

impl Plugin for FileLoggerPlugin

Source§

impl Plugin for ForwardAuthPlugin

Source§

impl Plugin for GoogleCloudLoggingPlugin

Source§

impl Plugin for GzipPlugin

Source§

impl Plugin for HmacAuthPlugin

Source§

impl Plugin for HttpLoggerPlugin

Source§

impl Plugin for IpRestrictionPlugin

Source§

impl Plugin for JweDecryptPlugin

Source§

impl Plugin for JwtAuthPlugin

Source§

impl Plugin for KeyAuthPlugin

Source§

impl Plugin for LagoPlugin

Source§

impl Plugin for LdapAuthPlugin

Source§

impl Plugin for LimitConnPlugin

Source§

impl Plugin for LimitCountPlugin

Source§

impl Plugin for ListenerPlugin

Source§

impl Plugin for LoggingPlugin

Source§

impl Plugin for LogglyPlugin

Source§

impl Plugin for LokiLoggerPlugin

Source§

impl Plugin for MockingPlugin

Source§

impl Plugin for MultiAuthPlugin

Source§

impl Plugin for OasValidatorPlugin

Source§

impl Plugin for OpaPlugin

Source§

impl Plugin for OpenFunctionPlugin

Source§

impl Plugin for OpenTelemetryPlugin

Source§

impl Plugin for OpenWhiskPlugin

Source§

impl Plugin for OpenidConnectPlugin

Source§

impl Plugin for PrometheusPlugin

Source§

impl Plugin for ProxyCachePlugin

Source§

impl Plugin for ProxyMirrorPlugin

Source§

impl Plugin for ProxyRewritePlugin

Source§

impl Plugin for RateLimitPlugin

Source§

impl Plugin for RealIpPlugin

Source§

impl Plugin for RedirectPlugin

Source§

impl Plugin for RefererRestrictionPlugin

Source§

impl Plugin for RequestIdPlugin

Source§

impl Plugin for RequestSizeLimitPlugin

Source§

impl Plugin for RequestValidationPlugin

Source§

impl Plugin for ResponseRewritePlugin

Source§

impl Plugin for ScriptPlugin

Source§

impl Plugin for ServerlessPostFunctionPlugin

Source§

impl Plugin for ServerlessPreFunctionPlugin

Source§

impl Plugin for SetVarsPlugin

Source§

impl Plugin for SkywalkingLoggerPlugin

Source§

impl Plugin for SkywalkingPlugin

Source§

impl Plugin for SlsLoggerPlugin

Source§

impl Plugin for SplunkHecLoggingPlugin

Source§

impl Plugin for StoreDeletePlugin

Source§

impl Plugin for StoreGetPlugin

Source§

impl Plugin for StoreIncrPlugin

Source§

impl Plugin for StoreSetPlugin

Source§

impl Plugin for SyslogPlugin

Source§

impl Plugin for TcpLoggerPlugin

Source§

impl Plugin for TencentCloudClsPlugin

Source§

impl Plugin for TrafficLabelPlugin

Source§

impl Plugin for TrafficSplitPlugin

Source§

impl Plugin for UaRestrictionPlugin

Source§

impl Plugin for UdpLoggerPlugin

Source§

impl Plugin for UpstreamPlugin

Source§

impl Plugin for UriBlockerPlugin

Source§

impl Plugin for WolfRbacPlugin

Source§

impl Plugin for WorkflowPlugin

Source§

impl Plugin for ZipkinPlugin