Skip to main content

QueueIngress

Struct QueueIngress 

Source
pub struct QueueIngress { /* private fields */ }
Expand description

Enqueues each message of a QueueSource into a DurableRunStore; see the module documentation.

Implementations§

Source§

impl QueueIngress

Source

pub fn new( source: Arc<dyn QueueSource>, store: Arc<dyn DurableRunStore>, mapper: impl Fn(&QueueMessage) -> Result<NewRun> + Send + Sync + 'static, ) -> Self

Creates an ingress with a batch of 10, a 1-second pull wait, and a 30-second redelivery delay after a failed enqueue.

Source

pub fn with_governance(self, governance: GovernanceControl) -> Self

Holds every pull while governance refuses work.

Source

pub fn with_batch_size(self, batch_size: usize) -> Self

Sets the most messages pulled per batch.

Source

pub fn with_pull_wait(self, wait: Duration) -> Self

Sets how long one pull waits for the first message.

Source

pub fn with_retry_after(self, retry_after: Duration) -> Self

Sets how long a nacked message waits before redelivery.

Source

pub fn with_max_pending(self, max_pending: usize) -> Self

Stops pulling while max_pending runs from this source are unfinished.

Source

pub fn idempotency_key(source: &str, message_id: &str) -> String

The idempotency key of the run a message wakes.

§Example
assert_eq!(adk_core::queue_source::QueueIngress::idempotency_key("orders", "m-1"), "queue:orders:m-1");
Source

pub async fn poll_once(&self) -> Result<IngressReport>

Pulls one batch and enqueues each message; see the module documentation.

§Errors

Returns an error when the pull fails. Per-message failures nack the message and are counted in IngressReport::nacked.

Source

pub async fn run(&self, idle: Duration, shutdown: impl Future<Output = ()>)

Polls until shutdown resolves, sleeping idle after a batch that pulled nothing.

§Example
let (stop, stopped) = tokio::sync::oneshot::channel::<()>();
let task = tokio::spawn(async move {
    ingress.run(Duration::from_millis(200), async { let _ = stopped.await; }).await
});
stop.send(()).ok();
task.await.unwrap();

Trait Implementations§

Source§

impl Clone for QueueIngress

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 QueueIngress

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for QueueIngress

§

impl !UnwindSafe for QueueIngress

§

impl Forget for QueueIngress

§

impl Freeze for QueueIngress
where *const ArcInner<dyn QueueSource> is !null: Freeze, PhantomData<ArcInner<dyn QueueSource>>: Freeze, *const ArcInner<dyn DurableRunStore> is !null: Freeze, PhantomData<ArcInner<dyn DurableRunStore>>: Freeze, *const ArcInner<dyn Fn(&QueueMessage) -> Result<NewRun, AdkError> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&QueueMessage) -> Result<NewRun, AdkError> + Sync + Send>>: Freeze, *const ArcInner<ControlState> is !null: Freeze, PhantomData<ArcInner<ControlState>>: Freeze,

§

impl Move for QueueIngress

§

impl Send for QueueIngress
where Arc<dyn QueueSource>: Send, Arc<dyn DurableRunStore>: Send, Arc<dyn Fn(&QueueMessage) -> Result<NewRun, AdkError> + Sync + Send>: Send, Arc<ControlState>: Send,

§

impl Sync for QueueIngress
where Arc<dyn QueueSource>: Sync, Arc<dyn DurableRunStore>: Sync, Arc<dyn Fn(&QueueMessage) -> Result<NewRun, AdkError> + Sync + Send>: Sync, Arc<ControlState>: Sync,

§

impl Unpin for QueueIngress
where Arc<dyn QueueSource>: Unpin, Arc<dyn DurableRunStore>: Unpin, Arc<dyn Fn(&QueueMessage) -> Result<NewRun, AdkError> + Sync + Send>: Unpin, Arc<ControlState>: Unpin,

§

impl UnsafeUnpin for QueueIngress
where *const ArcInner<dyn QueueSource> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn QueueSource>>: UnsafeUnpin, *const ArcInner<dyn DurableRunStore> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn DurableRunStore>>: UnsafeUnpin, *const ArcInner<dyn Fn(&QueueMessage) -> Result<NewRun, AdkError> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&QueueMessage) -> Result<NewRun, AdkError> + Sync + Send>>: UnsafeUnpin, *const ArcInner<ControlState> is !null: UnsafeUnpin, PhantomData<ArcInner<ControlState>>: UnsafeUnpin,

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> Same for T

Source§

type Output = T

Should always be Self
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