pub struct RegistryComponentContext { /* private fields */ }Expand description
Adapter that lets Registry participate as a ComponentContext.
Wraps the shared Arc<Mutex<Registry>> and delegates resolve_component
to Registry::get. The metrics collector is threaded in from the
composition root (camel-cli) at construction; it is the ADR-0066
late-bound handle, not a backend snapshot, so late registrations flow
through camel_component_api::ComponentContext::metrics without
re-snapshotting. The
components-lever snapshot gates only the component-operations family —
the error family is never lever-gated. When no collector is wired
(e.g. compile-time security scan, standalone examples without a
live context), construction resolves
camel_api::NoOpMetrics.
The registry reference is non-owning: the context holds only a
std::sync::Weak to the registry, so it never keeps the registry
(and, transitively, the CamelContext that owns it) alive.
Component resolution works only while a strong registry reference
exists elsewhere — the owning CamelContext, or an anchor the
embedder retains. Once the last strong reference drops, resolution
returns None.
Shutdown binding is optional: new leaves the context unbound
(compile-time scans, tests), while
with_shutdown_slot binds it to the
owning context’s shutdown-token slot so resolved producers observe
Runtime shutdown.
Implementations§
Source§impl RegistryComponentContext
impl RegistryComponentContext
Sourcepub fn new(
registry: Arc<Mutex<Registry>>,
metrics: Option<Arc<dyn MetricsCollector>>,
components_enabled: bool,
) -> Self
pub fn new( registry: Arc<Mutex<Registry>>, metrics: Option<Arc<dyn MetricsCollector>>, components_enabled: bool, ) -> Self
Builds the context, resolving the collector once: metrics when
wired, NoOpMetrics otherwise.
Sourcepub fn with_shutdown_slot(self, slot: Arc<Mutex<CancellationToken>>) -> Self
pub fn with_shutdown_slot(self, slot: Arc<Mutex<CancellationToken>>) -> Self
Binds this context to a shutdown-token slot that mirrors the
owning CamelContext’s CURRENT shutdown token.
The slot is written at context build time and re-written by every
start(), so shutdown_token
resolves the token per call: after a stop/start cycle the resolved
token is the new boot’s token, never a stale cancelled one. The
Arc shares only the slot — it does NOT extend the context’s
lifetime, mirroring this struct’s Weak-registry ownership: once
the owning context drops, its token is never cancelled (the same
observable outcome as resolve_component returning None).
Trait Implementations§
Source§impl ComponentContext for RegistryComponentContext
impl ComponentContext for RegistryComponentContext
Source§fn shutdown_token(&self) -> Option<CancellationToken>
fn shutdown_token(&self) -> Option<CancellationToken>
The owning context’s CURRENT shutdown token, read through the slot
mirror at call time (see with_shutdown_slot).
Poison-tolerant: a poisoned slot resolves None rather than
panicking, degrading to the slot-less default (callers mint an
uncancelled local root — fail-safe, never fail-boot).
Source§fn resolve_component(&self, scheme: &str) -> Option<Arc<dyn Component>>
fn resolve_component(&self, scheme: &str) -> Option<Arc<dyn Component>>
Source§fn resolve_language(&self, _name: &str) -> Option<Arc<dyn Language>>
fn resolve_language(&self, _name: &str) -> Option<Arc<dyn Language>>
Source§fn component_metrics_enabled(&self) -> bool
fn component_metrics_enabled(&self) -> bool
[observability.metrics].components lever —
gates only the uniform component-operations family served through
RuntimeObservability::component_metrics(); error-family
emission is never lever-gated. Default false (opt-in);
CamelContext overrides this with its MetricsLeversConfig
snapshot.Source§fn platform_service(&self) -> Arc<dyn PlatformService> ⓘ
fn platform_service(&self) -> Arc<dyn PlatformService> ⓘ
fn register_route_health_check( &self, _route_id: &str, _check: Arc<dyn AsyncHealthCheck>, )
fn unregister_route_health_check(&self, _route_id: &str)
Source§fn in_flight_counter(&self) -> Option<Arc<InFlightGauge>>
fn in_flight_counter(&self) -> Option<Arc<InFlightGauge>>
ConsumerContext at consumer start and read by
CamelContext::total_in_flight() for the drain verdict. Default
None keeps test contexts uncounted.Source§fn health(&self) -> Arc<dyn HealthCheckRegistry> ⓘ
fn health(&self) -> Arc<dyn HealthCheckRegistry> ⓘ
fn route_id(&self) -> Option<&str>
fn register_current_route_health_check(&self, check: Arc<dyn AsyncHealthCheck>)
Auto Trait Implementations§
impl !RefUnwindSafe for RegistryComponentContext
impl !UnwindSafe for RegistryComponentContext
impl Freeze for RegistryComponentContext
impl Send for RegistryComponentContext
impl Sync for RegistryComponentContext
impl Unpin for RegistryComponentContext
impl UnsafeUnpin for RegistryComponentContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> RuntimeObservability for Twhere
T: ComponentContext,
impl<T> RuntimeObservability for Twhere
T: ComponentContext,
Source§fn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ
fn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ
increment_errors(route_id, label)
per ADR-0012 categories (b′) and (e).Source§fn health(&self) -> Arc<dyn HealthCheckRegistry> ⓘ
fn health(&self) -> Arc<dyn HealthCheckRegistry> ⓘ
force_unhealthy_for_route(route_id, name, reason) per ADR-0012
category (g).Source§fn component_metrics(&self) -> ComponentMetrics
fn component_metrics(&self) -> ComponentMetrics
camel_component_operations_total{component,operation,outcome},
dashboard-observability Task 4.1). The lever snapshot is baked in
at facade construction: the component series flow only with the
[observability.metrics].components lever on, while failures
always reach the non-disableable error family. Read moreSource§fn in_flight_counter(&self) -> Option<Arc<InFlightGauge>>
fn in_flight_counter(&self) -> Option<Arc<InFlightGauge>>
ComponentContext::in_flight_counter.
Default None keeps runtimes that install no gauge uncounted.