Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shutdown options for the client classes #1917

Open
feywind opened this issue May 2, 2024 · 5 comments
Open

Add shutdown options for the client classes #1917

feywind opened this issue May 2, 2024 · 5 comments
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@feywind
Copy link
Collaborator

feywind commented May 2, 2024

We are planning to add updates to the close() methods to allow for a more deterministic shutdown process. This will take care of issues like these:

#1860
#1856
#1665
#1648

The three options boil down to this:

  • Wait for everything to finish dequeuing
  • Bail immediately (and maybe return IDs of things that were pending)
  • Nack everything in the queue and wait for those to send
@feywind feywind added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p3 Desirable enhancement or fix. May not be included in next release. labels May 2, 2024
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label May 2, 2024
@modestaspruckus
Copy link

modestaspruckus commented Sep 27, 2024

Hey, any update on this, when it's planned to have proper close method?

@mcasarrubios
Copy link

Hi @feywind, is there a time estimate planned for this? This is something we need to be able to do a graceful shutdown.
Thanks in advance

@mcasarrubios
Copy link

For us, the ideal solution would be this point ‘Wait for everything to finish dequeuing’.

@feywind
Copy link
Collaborator Author

feywind commented Nov 15, 2024

@mcasarrubios Thanks for the input. Right now you can already do the basic "wait for dequeue" using these methods:

  • subscriber.close()
  • topic.flush()

The extra thing we want to add is allowing options for how to handle outstanding data (e.g. drop everything on the floor and quit immediately).

@mcasarrubios
Copy link

Hey @feywind, thank you for your response. Could you please share an example of how to do this? I can't get it to work.

This is the flow I am trying:

1.- Receive a SIGTERM
2.- Call topic.flush() for each topic
3.- Delay 1 second to wait to everything is flushed
4.- Call subscription.close() for each subscription
5.- Wait several seconds to allow the messages to finish their execution and can send the ACK
6.- Continue with the shutdown

Everything works as expected until step 5. When we close the subscriptions no new messages come in for processing.
The problem is that the messages that are processing fail when they are going to ACK the message with the following error message:
"Error: INVALID : Subscriber closed\n at AckQueue.add..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants