pub struct QueueIngress { /* private fields */ }Expand description
Enqueues each message of a QueueSource into a DurableRunStore; see the
module documentation.
Implementations§
Source§impl QueueIngress
impl QueueIngress
Sourcepub fn new(
source: Arc<dyn QueueSource>,
store: Arc<dyn DurableRunStore>,
mapper: impl Fn(&QueueMessage) -> Result<NewRun> + Send + Sync + 'static,
) -> Self
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.
Sourcepub fn with_governance(self, governance: GovernanceControl) -> Self
pub fn with_governance(self, governance: GovernanceControl) -> Self
Holds every pull while governance refuses work.
Sourcepub fn with_batch_size(self, batch_size: usize) -> Self
pub fn with_batch_size(self, batch_size: usize) -> Self
Sets the most messages pulled per batch.
Sourcepub fn with_pull_wait(self, wait: Duration) -> Self
pub fn with_pull_wait(self, wait: Duration) -> Self
Sets how long one pull waits for the first message.
Sourcepub fn with_retry_after(self, retry_after: Duration) -> Self
pub fn with_retry_after(self, retry_after: Duration) -> Self
Sets how long a nacked message waits before redelivery.
Sourcepub fn with_max_pending(self, max_pending: usize) -> Self
pub fn with_max_pending(self, max_pending: usize) -> Self
Stops pulling while max_pending runs from this source are unfinished.
Sourcepub fn idempotency_key(source: &str, message_id: &str) -> String
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");Sourcepub async fn poll_once(&self) -> Result<IngressReport>
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.
Sourcepub async fn run(&self, idle: Duration, shutdown: impl Future<Output = ()>)
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();