pub trait ArclyPlugin:
Send
+ Sync
+ 'static {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn on_init<'a>(
&'a mut self,
ctx: &'a mut ArclyPluginContext,
) -> BoxFuture<'a, Result<(), PluginError>> { ... }
fn on_start<'a>(
&'a self,
container: &'static FrozenDiContainer,
) -> BoxFuture<'a, Result<(), PluginError>> { ... }
fn on_shutdown<'a>(
&'a self,
container: &'static FrozenDiContainer,
) -> BoxFuture<'a, Result<(), PluginError>> { ... }
}Expand description
Plugin lifecycle.
All three hooks receive the framework’s frozen DI container as a
&'static ref (after init completes), so background tasks and shutdown
drain routines can resolve injected services with zero locks. The init
hook receives the mutable ArclyPluginContext, through which the
plugin can provide<T> new singletons into the container before it
freezes.
Required Methods§
Provided Methods§
Sourcefn on_init<'a>(
&'a mut self,
ctx: &'a mut ArclyPluginContext,
) -> BoxFuture<'a, Result<(), PluginError>>
fn on_init<'a>( &'a mut self, ctx: &'a mut ArclyPluginContext, ) -> BoxFuture<'a, Result<(), PluginError>>
Pre-bind. Register providers, routes, interceptors, openapi mutators.
The container is built AFTER every plugin’s on_init returns.
Sourcefn on_start<'a>(
&'a self,
container: &'static FrozenDiContainer,
) -> BoxFuture<'a, Result<(), PluginError>>
fn on_start<'a>( &'a self, container: &'static FrozenDiContainer, ) -> BoxFuture<'a, Result<(), PluginError>>
Post-bind. Listener is live and accepting. Background tasks spawn
here. container resolves any provider — including ones the plugin
itself registered in on_init.
Sourcefn on_shutdown<'a>(
&'a self,
container: &'static FrozenDiContainer,
) -> BoxFuture<'a, Result<(), PluginError>>
fn on_shutdown<'a>( &'a self, container: &'static FrozenDiContainer, ) -> BoxFuture<'a, Result<(), PluginError>>
Graceful shutdown. Invoked after the HTTP server has stopped
accepting new connections and all in-flight requests have drained.
Wrapped by App in a configurable timeout (default 5s) so a hung
plugin can never wedge the process.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".