Clients that are missing backpressure for async publishing of JetStream messages can negatively impac the NATS servers and clusters.
Rust client separates publish with ack, as two separate futures, which is fine and very flexible, but does not enforce any backpressure, or enable easier handling of it. That is especially relevant for users dropping PublishAckFuture and ignoring the Ack entirely.
This PR addresses this in two ways:
Error on Context::publish if the threshold for in-flight acks is reached
Spin a task that awaits for acks for PubAckFuture that were dropped.
Challenges
A new background task was needed. This should be fine, as it idles if user does not drop acks.
Overview
Clients that are missing backpressure for async publishing of JetStream messages can negatively impac the NATS servers and clusters.
Rust client separates publish with ack, as two separate futures, which is fine and very flexible, but does not enforce any backpressure, or enable easier handling of it. That is especially relevant for users dropping
PublishAckFuture
and ignoring theAck
entirely.This PR addresses this in two ways:
Context::publish
if the threshold for in-flight acks is reachedPubAckFuture
that were dropped.Challenges
Context
.