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§
Sourcefn plugin_kind(&self) -> &str
fn plugin_kind(&self) -> &str
Returns the unique plugin kind string.
Sourcefn validate(&self, plugin_config: &Map<String, Json>) -> Vec<ConfigDiagnostic>
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.
Sourcefn register<'a>(
&'a self,
plugin_config: &Map<String, Json>,
ctx: &'a mut PluginRegistrationContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>
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§
Sourcefn allows_multiple_components(&self) -> bool
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.