pub trait ServerPlugin:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn run<'life0, 'async_trait>(
&'life0 self,
ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn rpc_methods(&self) -> Vec<RpcMethodDef> { ... }
fn placement(&self) -> Placement { ... }
fn runs_in_every_pool(&self) -> bool { ... }
}Expand description
Trait for plugins that run a single long-lived background task.
The run future should observe ctx.shutdown and return when signaled.
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Stable plugin name (same semantics as Plugin::name).
Sourcefn run<'life0, 'async_trait>(
&'life0 self,
ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run the plugin’s main loop. Return Ok(()) on shutdown.
Observe ctx.shutdown to detect the server shutdown signal.
Do not discard watch::RecvError with .ok() — treat it as an
unexpected condition (the sender was dropped without signaling shutdown)
and log an error:
if let Err(e) = ctx.shutdown.changed().await {
tracing::error!(error = %e, "shutdown sender dropped unexpectedly");
}Provided Methods§
Sourcefn rpc_methods(&self) -> Vec<RpcMethodDef>
fn rpc_methods(&self) -> Vec<RpcMethodDef>
Optional RPC method advertisements (default empty).
Sourcefn placement(&self) -> Placement
fn placement(&self) -> Placement
Where this plugin runs in the fork-after-warm model (phase 79).
Default Placement::WorkerOnly; see Plugin::placement.
Sourcefn runs_in_every_pool(&self) -> bool
fn runs_in_every_pool(&self) -> bool
Whether this plugin must be booted in every worker pool (phase 85).
Default false; see Plugin::runs_in_every_pool.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".