Expand description
ExtensionPoint<T>: a typed, name-indexed, hot-swappable collection.
In behest’s composable model, every pluggable category of runtime
element — chat providers, embedding providers, tools, context adapters,
stores, publishers, transports — is exposed as an
ExtensionPoint<T>. Operators compose a runtime by registering
implementations by name, and can replace any registered instance at
runtime.
§Design
- Name-indexed: every entry is keyed by a stable string. The same
name space is shared with the component registry, so config files can
reference extensions by name (e.g.
"primary","fallback-eu"). - Clonable: the inner state is wrapped in an
Arc, so cloning anExtensionPointis cheap. A clone observes every registration performed on the original. - Hot-swappable:
ExtensionPoint::replaceatomically swaps the storedArc<T>and returns the previous one. Callers holding the oldArccontinue to use it; newgetcalls return the new instance. - In-use detection:
ExtensionPoint::unregisterrefuses to drop an entry whose strong count is above the registry’s reference (one reference for the storage slot). This catches the common bug of removing a provider that is still serving a run.
§Example
use std::sync::Arc;
use behest_runtime::extension::ExtensionPoint;
let ep: ExtensionPoint<String> = ExtensionPoint::new();
ep.register("greeting", Arc::new("hello".to_string())).unwrap();
assert_eq!(ep.get("greeting").map(|s| (*s).clone()), Some("hello".to_string()));Structs§
- Extension
Point - Typed, name-indexed collection of
Arc<T>.
Enums§
- Extension
Error - Errors raised by
ExtensionPointoperations.