-
Notifications
You must be signed in to change notification settings - Fork 119
Pub/Sub - Nack messages on drop of handler #4514
Copy link
Copy link
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.
Milestone
Description
The Handler has a fn ack(self) and a fn nack(self). If the application drops the handler without calling either, we continue to hold the message in lease management, and continue to extend its lease, even though it can never be acknowledged by the application.
We should nack messages on drop. And we should consider just getting rid of h.nack(), when we can drop(h) instead.
To implement this, we will want to hold an inner state in an option1. Something like:
struct AtLeastOnce {
inner: Option<AtLeastOnceImpl>;
}
impl AtLeastOnce {
fn ack(self) {
if let Some(inner) = std::mem::take(self.inner) {
inner.ack(); // or whatever.
}
}
}
impl Drop for AtLeastOnce {
fn drop(&mut self) {
if let Some(inner) = std::mem::take(self.inner) {
inner.nack(); // or whatever.
}
}
}Footnotes
-
We cannot consume
selffor structs that have a manual drop. Unless we are willing to beunsafe. ↩
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.