-
Notifications
You must be signed in to change notification settings - Fork 0
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
Graceful shutdown #66
Open
jo-asplin-met-no
wants to merge
21
commits into
trunk
Choose a base branch
from
graceful_shutdown
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8a43508
Added initial code for graceful shutdown (Issue #45)
jo-asplin-met-no ffabee8
Typo (a bit pedantic, but still)
jo-asplin-met-no cb0d6cc
Refactored shutdown_signal to common package
jo-asplin-met-no df49f79
Moved shutdown_signal from common to util
jo-asplin-met-no 8b01706
Removed superfluous signals
jo-asplin-met-no bb46d2f
Assumed Unix + added comments
jo-asplin-met-no 3eff24a
Gracefully shut down kvkafka reader
jo-asplin-met-no d8ca2b6
Improved signal catching and task joining
jo-asplin-met-no dfa7bfb
Detected shutdown signal during end-to-end testing
jo-asplin-met-no ad49595
Don't generally await/join signal catcher task
jo-asplin-met-no 6d050b4
Another go at cancelling kvkafka reader from caught signal
jo-asplin-met-no 239b7c1
Remove `zero_to_none` function
Lun4m dc1a4c8
Create timeseries if label does not exist instead of returning Err
Lun4m 7b46af6
Merge branch 'trunk' into graceful_shutdown
jo-asplin-met-no a63842e
Fixed lint issue
jo-asplin-met-no d4ef671
Fixed comment
jo-asplin-met-no eb9bd05
Used block to have attribute apply to multiple statements
jo-asplin-met-no ce4fee5
Fixed typos
jo-asplin-met-no a42a035
Yet another go at cancelling kafka reader, but essentially back to or…
jo-asplin-met-no decdd6b
Added debug printout
jo-asplin-met-no 0c21b6c
Yet another go at cancelling kafka reader
jo-asplin-met-no File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ name = "generate_partition_queries" | |
|
||
[dependencies] | ||
chrono.workspace = true | ||
tokio.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
use tokio::signal; | ||
|
||
/// Returns a Future that completes once a signal to shutdown the service is caught. | ||
pub async fn shutdown_signal() { | ||
let ctrl_c = async { | ||
signal::ctrl_c() // aka. SIGINT on Unix | ||
.await | ||
.expect("failed to install Ctrl+C (SIGINT) handler"); | ||
}; | ||
|
||
#[cfg(unix)] | ||
let sigterm = async { | ||
signal::unix::signal(signal::unix::SignalKind::terminate()) | ||
.expect("failed to install signal handler for SIGTERM") | ||
.recv() | ||
.await; | ||
}; | ||
#[cfg(not(unix))] | ||
let sigterm = std::future::pending::<()>(); | ||
Lun4m marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// TODO: add more signals that should result in a shutdown? | ||
|
||
tokio::select! { | ||
_ = ctrl_c => {}, | ||
_ = sigterm => {}, | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The leading scoping operator before
util
looks a little odd here, is it correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it compiles. But I'll take a look ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The leading scoping operator needs to be there for the code to compile. But maybe there's a better idiom to use in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is a namespace confict with the
util
module in this crate. We should maybe consider renaming one of them to avoid confusion. Or perhaps we can just move the contents of the util module into the util crate instead.