Skip to main content

Module component

Module component 

Source
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 dropped
  • Component::init is the only phase that takes a configuration value. It must be a pure constructor: no side effects, no network calls.
  • Component::start opens connections, spawns background tasks, and registers with external systems. It must be idempotent: re-starting a component that is already started should succeed.
  • Component::stop is the inverse of start. It must drain in-flight work, close connections, and persist pending state. Idempotent.
  • Component::health is 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§

ComponentContext
Context handed to Component::init and propagated through dependent components.

Enums§

AnyComponentError
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 via AnyComponent::as_any_arc.

Traits§

AnyComponent
Object-safe view of a Component instance, used by the registry to store and drive components of heterogeneous types uniformly.
Component
The core contract every pluggable runtime element implements.