pub trait Plugin:
Send
+ Sync
+ 'static {
Show 14 methods
// Required methods
fn id(&self) -> &'static str;
fn name(&self) -> &'static str;
// Provided methods
fn version(&self) -> &'static str { ... }
fn depends_on(&self) -> &[&'static str] { ... }
fn is_required(&self, ctx: &StartupContext<'_>) -> bool { ... }
fn is_plugin(&self) -> bool { ... }
fn is_critical(&self) -> bool { ... }
fn config_toml(&self) -> Option<&'static str> { ... }
fn schemas(&self) -> Vec<&'static str> { ... }
fn resources(&self, ctx: &mut RegistrationContext) -> Result<()> { ... }
fn register_hooks(&self) -> Result<()> { ... }
fn on_ready(&self, ctx: &Context) -> Result<()> { ... }
fn install_event_subscriber(
&self,
ctx: &Context,
) -> Result<Option<TelemetryService>> { ... }
fn on_shutdown(&self) { ... }
}Expand description
Contract between the yeti binary and service crates.
The runtime calls methods in order:
is_required() → schemas() → resources() → on_ready() → on_shutdown()
schemas() is called during discovery (before backends exist).
resources() is called during loading (after backends exist).
Each is called exactly once.
Required Methods§
Provided Methods§
Sourcefn depends_on(&self) -> &[&'static str]
fn depends_on(&self) -> &[&'static str]
Plugin IDs this service depends on (for topological ordering).
Sourcefn is_required(&self, ctx: &StartupContext<'_>) -> bool
fn is_required(&self, ctx: &StartupContext<'_>) -> bool
Whether this service should be activated given the current config.
Sourcefn is_critical(&self) -> bool
fn is_critical(&self) -> bool
Whether registration failure should abort startup.
Sourcefn config_toml(&self) -> Option<&'static str>
fn config_toml(&self) -> Option<&'static str>
Embedded Cargo.toml content. Discovery extracts
[package.metadata.app] (and any plugin metadata blocks) via
yeti_sdk_host::application::cargo_manifest.
Sourcefn schemas(&self) -> Vec<&'static str>
fn schemas(&self) -> Vec<&'static str>
GraphQL schema strings. Called once during discovery, before backends exist. Filesystem apps return empty — their schemas come from schema.graphql files.
Sourcefn resources(&self, ctx: &mut RegistrationContext) -> Result<()>
fn resources(&self, ctx: &mut RegistrationContext) -> Result<()>
Register resources, hooks, web files, and providers. Called once during loading, after backends exist.
Sourcefn register_hooks(&self) -> Result<()>
fn register_hooks(&self) -> Result<()>
Register in-process hook services (ADR-009).
Called by the app loader between Self::resources and
Self::on_ready. Static plugins that want to install
services into another static plugin’s hook chain (e.g.
yeti-auth’s OAuth/Token chains, yeti-mcp’s tool/resource
chains) call the per-domain hook surface directly here (e.g.
yeti_mcp::McpHooks::register_list_tools_service), once per
chain they want to extend.
Slotted before on_ready so registrations are visible by the
time any request can hit a dispatcher that reads the chain.
Default-empty so existing plugins compile unchanged.
Sourcefn on_ready(&self, ctx: &Context) -> Result<()>
fn on_ready(&self, ctx: &Context) -> Result<()>
Post-registration setup (bootstrap data, background tasks, etc.).
Receives a Context with request-less defaults (no method/headers/body).
The runtime populates backend_manager, root_directory, app_id,
and pubsub_lookup before calling.
Sourcefn install_event_subscriber(
&self,
ctx: &Context,
) -> Result<Option<TelemetryService>>
fn install_event_subscriber( &self, ctx: &Context, ) -> Result<Option<TelemetryService>>
Build and return the service’s telemetry-subscriber Service, if any.
Per ADR-006 this returns a TelemetryService (Tower
Service<TelemetryEvent>) instead of the legacy
Box<dyn EventSubscriber>. The runtime creates an mpsc
channel, registers the sender globally so any code can
event_sender().send(event) to fire an event, and drives a
per-event call loop on the host tokio runtime:
while let Some(ev) = rx.recv().await {
if let Ok(svc) = service.ready().await {
let _ = svc.call(ev).await;
}
}Plugin authors stack tower::ServiceBuilder layers
(timeout, trace, concurrency-limit) onto the Service before
returning it.
Default: no subscriber.
Sourcefn on_shutdown(&self)
fn on_shutdown(&self)
Called during graceful shutdown.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".