Skip to main content

Endpoint

Trait Endpoint 

Source
pub trait Endpoint: Send + Sync {
    // Required methods
    fn uri(&self) -> &str;
    fn create_consumer(
        &self,
        rt: Arc<dyn RuntimeObservability>,
    ) -> Result<Box<dyn Consumer>, CamelError>;
    fn create_producer(
        &self,
        rt: Arc<dyn RuntimeObservability>,
        ctx: &ProducerContext,
    ) -> Result<BoxProcessor, CamelError>;

    // Provided methods
    fn body_contract(&self) -> Option<BodyType> { ... }
    fn polling_consumer(&self) -> Option<Box<dyn PollingConsumer>> { ... }
    fn lifecycle(&self) -> Option<Arc<dyn StepLifecycle>> { ... }
}
Expand description

An Endpoint represents a source or destination in a route URI.

Required Methods§

Source

fn uri(&self) -> &str

The URI that identifies this endpoint.

Source

fn create_consumer( &self, rt: Arc<dyn RuntimeObservability>, ) -> Result<Box<dyn Consumer>, CamelError>

Create a consumer that reads from this endpoint.

rt provides narrow observability access (metrics() + health()) per ADR-0012 Phase A. Consumers store the Arc for later rt.metrics().increment_errors(...) / rt.health().force_unhealthy_for_route(...) calls (Phase B).

Source

fn create_producer( &self, rt: Arc<dyn RuntimeObservability>, ctx: &ProducerContext, ) -> Result<BoxProcessor, CamelError>

Create a producer that writes to this endpoint.

rt provides narrow observability access (metrics() + health()) per ADR-0012 Phase A. Producers store the Arc for later rt.health().force_unhealthy_for_route(...) calls on creation failure (Phase B category (g) sites).

Provided Methods§

Source

fn body_contract(&self) -> Option<BodyType>

Optional body type contract for the producer.

When Some(t), the pipeline will coerce the body to t before calling the producer. Default: None (accept any body variant, zero overhead).

Source

fn polling_consumer(&self) -> Option<Box<dyn PollingConsumer>>

Return a polling consumer for this endpoint, if supported.

Polling consumers use a pull model — callers invoke PollingConsumer::receive to retrieve the next message. Endpoints that only support push-based consumption should leave this default (returns None).

Source

fn lifecycle(&self) -> Option<Arc<dyn StepLifecycle>>

Return this endpoint’s lifecycle handle, if it is stateful.

Endpoints that own background work beyond a single process() call (timers, buckets, gap-detectors, queues) should override this to expose a StepLifecycle for the runtime to start and shut down in route order. Default: None (stateless; the common case).

Mirrors the contract on the Endpoint trait only — see CompiledStep::Process.lifecycle in camel-core for the consumer side. The returned handle is an Arc<dyn StepLifecycle> so it can be cloned into the compiled pipeline snapshot and shared across the route controller without extra ownership plumbing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§