跳到主要内容
本页尚未翻译

下面显示的是英文原文。

ack_extension

ack_extension sets how far each background extension of a delivery's lease reaches, from 10 seconds to 10 minutes, 60 seconds by default.

Pub/Sub redelivers a message whose ack deadline passes before it is settled. While a handler works, the client library extends that deadline in the background, each time by this much. A longer extension means fewer calls for a slow handler. A shorter one brings a delivery back sooner when the process dies, because the service redelivers once the last extension runs out. The client clamps the value to the 10 seconds to 10 minutes Pub/Sub accepts. It is independent of the ack deadline configured on the subscription. How long the client keeps extending one delivery is max_lease.

Example​

A report takes minutes to render, so each extension reaches five minutes.

/// A report takes minutes to render, so each extension of its lease reaches five minutes.
#[subscriber(
GooglePubSub::new("flow-reports-workers")
.create_with_topic("flow-reports")
.ack_extension(Duration::from_mins(5))
)]
async fn render(report: &Report) -> HandlerOutcome {
tracing::info!(report.id, "report rendered");
HandlerOutcome::ack()
}