Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin:
    Send
    + Sync
    + 'static {
    // Required methods
    fn plugin_kind(&self) -> &str;
    fn validate(
        &self,
        plugin_config: &Map<String, Json>,
    ) -> Vec<ConfigDiagnostic>;
    fn register<'a>(
        &'a self,
        plugin_config: &Map<String, Json>,
        ctx: &'a mut PluginRegistrationContext,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;

    // Provided method
    fn allows_multiple_components(&self) -> bool { ... }
}
Expand description

Implemented by custom plugins that register runtime middleware.

Required Methods§

Source

fn plugin_kind(&self) -> &str

Returns the unique plugin kind string.

Source

fn validate(&self, plugin_config: &Map<String, Json>) -> Vec<ConfigDiagnostic>

Validates one plugin component config.

Returning error-level diagnostics prevents initialize_plugins(...) from activating the configuration.

Source

fn register<'a>( &'a self, plugin_config: &Map<String, Json>, ctx: &'a mut PluginRegistrationContext, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Registers runtime middleware/subscribers for one plugin component.

The provided PluginRegistrationContext is component-scoped. Any error aborts the current initialization and triggers rollback of registrations created during the failed activation attempt.

Provided Methods§

Source

fn allows_multiple_components(&self) -> bool

Returns whether the plugin kind can appear multiple times in the config.

Return false for singleton components such as the built-in adaptive component.

Implementors§