Skip to main content

AggregatorService

Struct AggregatorService 

Source
pub struct AggregatorService { /* private fields */ }

Implementations§

Source§

impl AggregatorService

Source

pub fn new( config: AggregatorConfig, late_tx: Sender<AggregateEmission>, language_registry: SharedLanguageRegistry, route_cancel: CancellationToken, ) -> Self

Lifecycle invariant: sweep_cancel is initially seeded from the route’s cancellation token and wrapped in a swappable Arc<Mutex<...>> cell. StepLifecycle::start replaces it with a fresh token so the sweep respawns after a restart. Construction is runtime-free (no tokio::spawn here). The maintenance sweep task (TTL eviction when bucket_ttl is set, queue-depth sampling when queue_metrics is set) is spawned LAZILY on the first poll_ready and bound to the current sweep_cancel token via select!. The route owner MUST call shutdown to cancel it; Drop also aborts it as defense-in-depth.

Source

pub fn with_queue_metrics( self, metrics: Arc<dyn MetricsCollector>, label: impl Into<String>, ) -> Self

Inject queue-depth reporting: the TTL-sweep maintenance pass publishes the buffered group count (open correlation buckets) as camel_queue_depth{queue = label}. label is the route-scoped closed-set identifier (aggregator:<route>).

Source

pub fn config(&self) -> &AggregatorConfig

Source

pub fn has_timeout(&self) -> bool

Source

pub fn force_complete_all(&self)

Source

pub fn release_unarmed_buckets(&self)

Consumer-exit release (bd rc-iioeq): discard buckets with NO armed timeout task, leave armed buckets untouched.

After a natural consumer exit no further exchanges arrive, so a bucket without an armed timeout task can never complete on its own — its buffered exchanges are released eagerly (the same discard semantics force_complete_all applies with force_completion_on_stop=false). A bucket WITH an armed timeout task is left alone: that task owns its completion and emits through the late channel when the timeout fires.

Arming is decided per bucket in call: when the max_timeout_tasks cap is reached, a timeout-configured bucket stays unarmed. Without this release such a bucket would be orphaned forever — the bucket_ttl sweep only runs inside call on the next exchange, which never arrives after consumer exit.

Source§

impl AggregatorService

Source

pub async fn submit_with_claim( &self, exchange: Exchange, claim: Option<InFlightClaim>, ) -> AggregationReceipt

Submit one exchange with its drainclaim sidecar (drainclaim claim propagation) — the route loop’s aggregate entry point.

Behaviorally identical to the tower Service::call this is extracted from, except the claim travels with the exchange: a pending stash moves it into the bucket, a sync completion returns it (with the rest of the bucket’s claims) to the caller to hold across the aggregated exchange’s continuation, and every rejection path (bad correlation key, bucket caps) drops it — rejected means released.

Trait Implementations§

Source§

impl Clone for AggregatorService

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AggregatorService

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for AggregatorService

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Service<Exchange> for AggregatorService

Source§

type Response = Exchange

Responses given by the service.
Source§

type Error = CamelError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Exchange, CamelError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), CamelError>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, exchange: Exchange) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl StepLifecycle for AggregatorService

Source§

fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Resets the sweep for a fresh lifecycle: replaces the cancellation token with a new one and aborts any existing sweep handle so the next poll_ready respawns the sweep bound to the new token.

Source§

fn name(&self) -> &'static str

Stable name for logging/diagnostics.
Source§

fn shutdown<'life0, 'async_trait>( &'life0 self, reason: StepShutdownReason, ) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<P> Processor for P
where P: Service<Exchange, Response = Exchange, Error = CamelError> + Clone + Send + Sync + 'static,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, Request> ServiceExt<Request> for T
where T: Service<Request> + ?Sized,

Source§

fn ready(&mut self) -> Ready<'_, Self, Request>
where Self: Sized,

Yields a mutable reference to the service when it is ready to accept a request.
Source§

fn ready_oneshot(self) -> ReadyOneshot<Self, Request>
where Self: Sized,

Yields the service when it is ready to accept a request.
Source§

fn oneshot(self, req: Request) -> Oneshot<Self, Request>
where Self: Sized,

Consume this Service, calling it with the provided request once it is ready.
Source§

fn call_all<S>(self, reqs: S) -> CallAll<Self, S>
where Self: Sized, S: Stream<Item = Request>,

Process all requests from the given Stream, and produce a Stream of their responses. Read more
Source§

fn and_then<F>(self, f: F) -> AndThen<Self, F>
where Self: Sized, F: Clone,

Executes a new future after this service’s future resolves. This does not alter the behaviour of the poll_ready method. Read more
Source§

fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
where Self: Sized, F: FnOnce(Self::Response) -> Response + Clone,

Maps this service’s response value to a different value. This does not alter the behaviour of the poll_ready method. Read more
Source§

fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: FnOnce(Self::Error) -> Error + Clone,

Maps this service’s error value to a different value. This does not alter the behaviour of the poll_ready method. Read more
Source§

fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
where Self: Sized, Error: From<Self::Error>, F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,

Maps this service’s result type (Result<Self::Response, Self::Error>) to a different value, regardless of whether the future succeeds or fails. Read more
Source§

fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
where Self: Sized, F: FnMut(NewRequest) -> Request,

Composes a function in front of the service. Read more
Source§

fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
where Self: Sized, Error: From<Self::Error>, F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone, Fut: Future<Output = Result<Response, Error>>,

Composes an asynchronous function after this service. Read more
Source§

fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
where Self: Sized, F: FnMut(Self::Future) -> Fut, Error: From<Self::Error>, Fut: Future<Output = Result<Response, Error>>,

Composes a function that transforms futures produced by the service. Read more
Source§

fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
where Self: Sized + Send + 'static, Self::Future: Send + 'static,

Convert the service into a Service + Send trait object. Read more
Source§

fn boxed_clone(self) -> BoxCloneService<Request, Self::Response, Self::Error>
where Self: Sized + Clone + Send + 'static, Self::Future: Send + 'static,

Convert the service into a Service + Clone + Send trait object. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more