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

feat(jstzd): implement shutdown signal in jstzd server #688

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

huancheng-trili
Copy link
Collaborator

Context

Part of JSTZ-168.

JSTZ-168

Description

Implement shutdown signal in jstzd server.

If a program spins up jstzd server and keeps it running, it needs a way to know when jstzd server is terminated, e.g. after someone calls the shutdown endpoint. Otherwise, the program would just hang there not knowing when it can exit. This PR adds a wait method to achieve that. When wait finally returns, it means that jstzd server is shut down.

Manually testing the PR

  • Integration test: updated jstzd test to verify that wait actually works

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 47.63%. Comparing base (646ba92) to head (54ce88f).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/jstzd/src/task/jstzd.rs 84.61% 0 Missing and 2 partials ⚠️
Files with missing lines Coverage Δ
crates/jstzd/src/task/jstzd.rs 73.46% <84.61%> (+0.19%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 646ba92...54ce88f. Read the comment docs.

@huancheng-trili huancheng-trili marked this pull request as ready for review November 25, 2024 16:54
@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-7 branch from 05b4280 to bf1e11c Compare November 29, 2024 09:29
@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-8 branch from b79b8e9 to 92a578e Compare November 29, 2024 09:38
@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-7 branch from bf1e11c to 0857f6f Compare November 29, 2024 13:40
@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-8 branch from 92a578e to 3748079 Compare November 29, 2024 13:41
@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-7 branch from 0857f6f to f5fbf93 Compare November 29, 2024 15:38
@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-8 branch from 3748079 to 3e03410 Compare November 29, 2024 15:39
Base automatically changed from huanchengchang-jstz-168-7 to main November 29, 2024 15:46
@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-8 branch from 3e03410 to 9c2a4a5 Compare November 29, 2024 15:50
@zcabter zcabter self-requested a review December 2, 2024 11:55
Copy link
Collaborator

@ryutamago ryutamago left a comment

Choose a reason for hiding this comment

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

🚀

@huancheng-trili huancheng-trili force-pushed the huanchengchang-jstz-168-8 branch from 9c2a4a5 to 54ce88f Compare December 2, 2024 14:47
@huancheng-trili
Copy link
Collaborator Author

huancheng-trili commented Dec 2, 2024

Offline discussion: channel population is postponed to run being called to prevent the following situation from happening:

let server = JstzdServer::new(...);
server.wait().await;   // <- waits indefinitely because the server is not yet running and thus there's no way to trigger the signal sender

Since the whole run method is not atomic, technically speaking, it's possible that something happens between spawning the server and setting the channel and prevents things from running as expected. This should be fine for now since JstzdServer is not clone-able and thus it's not possible to interrupt run asynchronously.

@huancheng-trili huancheng-trili merged commit 4be32b4 into main Dec 2, 2024
5 checks passed
@huancheng-trili huancheng-trili deleted the huanchengchang-jstz-168-8 branch December 2, 2024 15:08
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.

2 participants