max_outstanding
max_outstanding caps how many deliveries may be unsettled at once; Pub/Sub stops sending at the cap and resumes below it.
A delivery is outstanding from the moment the service receives it until a handler settles it.
The limit travels with the streaming pull, and the service holds the stream to it.
It applies to one stream, not to the subscription as a whole: two instances of the service each hold their own share.
The default is the client library's 1000 messages; a value of zero or less sets no limit.
A delivery held by retry_after stays outstanding until it comes back.
The client also caps outstanding bytes at 100 MiB, a limit the descriptor leaves at its default.
Example
At most 50 orders are unsettled at once.
- Macros
- Manual
/// At most 50 orders are unsettled at once; the service holds the rest back.
#[subscriber(
GooglePubSub::new("flow-orders-workers")
.create_with_topic("flow-orders")
.max_outstanding(50)
)]
async fn index(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "order indexed");
HandlerOutcome::ack()
}
/// At most 50 orders are unsettled at once; the service holds the rest back.
fn orders() -> GooglePubSub {
GooglePubSub::new("flow-orders-workers")
.create_with_topic("flow-orders")
.max_outstanding(50)
}