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

provide graceful shutdown interface #8

Merged
merged 2 commits into from
Oct 13, 2024
Merged

Conversation

maxcountryman
Copy link
Owner

This introduces a mechanism for politely asking Underway to shutdown. To do so, a new function, graceful_shutdown is provided. Calling this function will send a notification to a Postgres channel. Workers listen on this channel and when a message is received will stop processing new tasks. If they're already processing a task, then they wait until that task is done or the task timeout has elapsed, whichever is first.

In order to cleanly stop the queue, this function should be used. If stopping in-progress tasks is safe for your use case, then this can be ignored and the queue can be stopped without any delay.

Closes #5

This introduces a mechanism for politely asking Underway to shutdown. To
do so, a new function, `graceful_shutdown` is provided. Calling this
function will send a notification to a Postgres channel. Workers listen
on this channel and when a message is received will stop processing new
tasks. If they're already processing a task, then they wait until that
task is done or the task timeout has elapsed, whichever is first.

In order to cleanly stop the queue, this function should be used. If
stopping in-progress tasks is safe for your use case, then this can be
ignored and the queue can be stopped without any delay.

Closes #5
@maxcountryman maxcountryman force-pushed the graceful-shutdown branch 2 times, most recently from 9501c1a to f14f47f Compare October 13, 2024 17:24
This allows workers to spawn up to the set limit task processing
routines.

Note that each worker is given a limit rather than workers sharing a
total limit.

Furthermore, `JoinSet` is used to simplify shutdown logic.
@maxcountryman maxcountryman merged commit 03e956b into main Oct 13, 2024
4 checks passed
@maxcountryman maxcountryman deleted the graceful-shutdown branch October 13, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graceful shutdowns
1 participant