Skip to content

Subscriber configurable shutdown behavior #4868

@dbolduc

Description

@dbolduc

We want to offer the following shutdown behavior (not necessarily as an option like this).

pub enum ShutdownBehavior {
    /// The subscriber flushes all pending acks from the application. No further
    /// acks are accepted. The lease loop is closed.
    ///
    /// All other messages under lease management are immediately nacked,
    /// regardless of if they have been returned to the application, or not.
    ///
    /// The shutdown is complete when all pending ack/nack RPCs have completed.
    NackImmediately,

    /// The subscriber will continue to accept acks, for messages it has
    /// delivered to the application. The subscriber will continue to extend
    /// leases for these messages while it waits.
    ///
    /// The subscriber may know about messages that have not been served to the
    /// application yet. These messages are immediately nacked.
    ///
    /// The shutdown is complete when all message handles delivered to the
    /// application have been used, and all pending ack/nack RPCs have
    /// completed.
    WaitForProcessing,
}

We also need a way to await these pending operations completing, likely by returning a StreamHandle. Maybe something like this:

pub struct StreamHandle {
  lease_loop: JoinHandle<()>,
}

impl StreamHandle {
  pub async fn shutdown(self, o: ShutdownBehavior);
}

or options are configured on the builder, and it is just StreamHandle::shutdown(self).

or as @coryan suggests, by encoding the options as separate functions like:

impl StreamHandle {
  pub async fn abandon(self); // NackImmediately
  pub async fn shutdown(self); // WaitForProcessing
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: pubsubIssues related to the Pub/Sub API.priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions