Expand description
The Component trait: lifecycle contract for every pluggable runtime
building block.
In behest, every pluggable element — chat providers, embedding
providers, tools, context adapters, stores, event publishers, snapshot
stores, RAG adapters, and the transport layer — implements Component.
This gives the runtime a uniform shape for: declarative configuration,
ordered initialization, lifecycle management, and health aggregation.
§Lifecycle
register factory ──► init ──► start ──► [serve] ──► stop
│
└──► on init error: instance is droppedComponent::initis the only phase that takes a configuration value. It must be a pure constructor: no side effects, no network calls.Component::startopens connections, spawns background tasks, and registers with external systems. It must be idempotent: re-starting a component that is already started should succeed.Component::stopis the inverse ofstart. It must drain in-flight work, close connections, and persist pending state. Idempotent.Component::healthis a non-mutating probe. It must be cheap (sub-millisecond) and safe to call from a hot path.
§Errors
Every phase returns Result<_, Self::Error>. The associated error type
must be a std::error::Error so that the registry can format it
uniformly. The trait is deliberately typed: implementations are free to
use the most precise error type (e.g. reqwest::Error for HTTP
providers) without forcing the registry to model every variant.
§Hot-plugging
Components are not required to be hot-swappable. The trait provides the
primitive contract; hot-swap semantics live in the
ExtensionPoint layer,
which is responsible for atomic reference replacement and live-reference
detection.
Structs§
- Component
Context - Context handed to
Component::initand propagated through dependent components.
Enums§
- AnyComponent
Error - Type-erased error from a boxed
AnyComponent. The original typed error is preserved as a string for log purposes; if callers need the typed error they should downcast viaAnyComponent::as_any_arc.
Traits§
- AnyComponent
- Object-safe view of a
Componentinstance, used by the registry to store and drive components of heterogeneous types uniformly. - Component
- The core contract every pluggable runtime element implements.