pub trait ComponentContext: Send + Sync {
// Required methods
fn resolve_component(&self, scheme: &str) -> Option<Arc<dyn Component>>;
fn resolve_language(&self, name: &str) -> Option<Arc<dyn Language>>;
fn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ;
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);
// Provided methods
fn in_flight_counter(&self) -> Option<Arc<InFlightGauge>> { ... }
fn component_metrics_enabled(&self) -> bool { ... }
fn health(&self) -> Arc<dyn HealthCheckRegistry> ⓘ { ... }
fn shutdown_token(&self) -> Option<CancellationToken> { ... }
fn route_id(&self) -> Option<&str> { ... }
fn register_current_route_health_check(
&self,
check: Arc<dyn AsyncHealthCheck>,
) { ... }
}Expand description
Runtime context passed to components during endpoint creation.
Required Methods§
Sourcefn resolve_component(&self, scheme: &str) -> Option<Arc<dyn Component>>
fn resolve_component(&self, scheme: &str) -> Option<Arc<dyn Component>>
Resolve a component by scheme.
Sourcefn resolve_language(&self, name: &str) -> Option<Arc<dyn Language>>
fn resolve_language(&self, name: &str) -> Option<Arc<dyn Language>>
Resolve a language by name.
Sourcefn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ
fn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ
Access the active metrics collector.
Sourcefn platform_service(&self) -> Arc<dyn PlatformService> ⓘ
fn platform_service(&self) -> Arc<dyn PlatformService> ⓘ
Access the active platform service.
fn register_route_health_check( &self, route_id: &str, check: Arc<dyn AsyncHealthCheck>, )
fn unregister_route_health_check(&self, route_id: &str)
Provided Methods§
Sourcefn in_flight_counter(&self) -> Option<Arc<InFlightGauge>>
fn in_flight_counter(&self) -> Option<Arc<InFlightGauge>>
Context-global gauge of accepted-not-completed exchanges
(drainclaim). Production contexts return the gauge installed on
every ConsumerContext at consumer start and read by
CamelContext::total_in_flight() for the drain verdict. Default
None keeps test contexts uncounted.
Sourcefn component_metrics_enabled(&self) -> bool
fn component_metrics_enabled(&self) -> bool
Snapshot of the [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.
Sourcefn health(&self) -> Arc<dyn HealthCheckRegistry> ⓘ
fn health(&self) -> Arc<dyn HealthCheckRegistry> ⓘ
Access the active health-check registry.
Used by component code paths that need to pin a route Unhealthy (category (g) per ADR-0012). Default: NoOp — tests/examples inherit the no-op. Concrete runtimes (CamelContext) override to return the real registry.
Sourcefn shutdown_token(&self) -> Option<CancellationToken>
fn shutdown_token(&self) -> Option<CancellationToken>
Clone of the Runtime-owned shutdown token when this context is
bound to one. Producer-side and processor-side code (which has no
ConsumerContext) uses it to observe Runtime shutdown.
CamelContext overrides this with its shutdown_token(). Default
None keeps unbound contexts (tests, examples) out of the
shutdown lineage, so callers mint a local root token instead.
Callers resolve this per call: CamelContext replaces its shutdown
token on every start, so a token captured once goes stale across
stop/start.
§Binding-time boundary
Token lineage binds at component REGISTRATION time. Production
registration sites construct slot-bound contexts
(RegistryComponentContext::with_shutdown_slot, re-written by
every CamelContext::start) and hand them to long-lived components
(for example WasmComponent’s captured Arc<dyn ComponentContext>).
Endpoint-creation-time adapter contexts
(ControllerComponentContext, MasterDelegateContext) must NOT
snapshot tokens; they keep the None default so no stale-across
stop/start lineage can leak, and callers mint a local root instead.
fn route_id(&self) -> Option<&str>
fn register_current_route_health_check(&self, check: Arc<dyn AsyncHealthCheck>)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".