Skip to content

Add async gracefulShutdown function to wait on graceful shutdown trigger #158

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

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Sep 11, 2023

Motivation

Sometimes, it's useful to wait for graceful shutdown to happen before resuming execution on a task.

This can be of particular interest when we don't have anything to do in a Service's run method but want to make sure some cleanup happens on graceful shutdown.
In this scenario, we can achieve this by calling await gracefulShutdown() in run(), followed by whatever cleanup we must do.

Modification

This PR adds a new gracefulShutdown() function to the GracefulShutdown suite.

Result

A new gracefulShutdown() method in the GracefulShutdown suite.

@gjcairo gjcairo requested a review from FranzBusch September 11, 2023 16:20
Copy link
Contributor

@FranzBusch FranzBusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@FranzBusch
Copy link
Contributor

@swift-server-bot test this please

@FranzBusch
Copy link
Contributor

@swift-server-bot add to allowlist

@gjcairo gjcairo changed the title Add waitForGracefulShutdown Add async gracefulShutdown function to wait on graceful shutdown trigger Sep 12, 2023
@FranzBusch
Copy link
Contributor

@swift-server-bot add to allowlist

@FranzBusch
Copy link
Contributor

@swift-server-bot test this please

@gjcairo gjcairo force-pushed the wait-for-shutdown branch 2 times, most recently from dafe956 to 87d3e2b Compare September 12, 2023 15:48
@gjcairo
Copy link
Collaborator Author

gjcairo commented Sep 13, 2023

@swift-server-bot test this please

@gjcairo
Copy link
Collaborator Author

gjcairo commented Sep 13, 2023

@swift-server-bot test this please

@gjcairo gjcairo merged commit 45a31b6 into main Sep 13, 2023
@gjcairo gjcairo deleted the wait-for-shutdown branch September 13, 2023 13:37
@FranzBusch FranzBusch added the 🆕 semver/minor Adds new public API. label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants