Skip to main content

ComponentContext

Trait ComponentContext 

Source
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§

Source

fn resolve_component(&self, scheme: &str) -> Option<Arc<dyn Component>>

Resolve a component by scheme.

Source

fn resolve_language(&self, name: &str) -> Option<Arc<dyn Language>>

Resolve a language by name.

Source

fn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ

Access the active metrics collector.

Source

fn platform_service(&self) -> Arc<dyn PlatformService> ⓘ

Access the active platform service.

Source

fn register_route_health_check( &self, route_id: &str, check: Arc<dyn AsyncHealthCheck>, )

Source

fn unregister_route_health_check(&self, route_id: &str)

Provided Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn route_id(&self) -> Option<&str>

Source

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".

Implementors§