Skip to content

[#1221] feat(rust): Add grpc graceful shutdown - #1292

Merged
zuston merged 11 commits into
apache:masterfrom
wenlongbrother:users/wenlong/AddGrpcGracefulShutDown
Nov 6, 2023
Merged

[#1221] feat(rust): Add grpc graceful shutdown#1292
zuston merged 11 commits into
apache:masterfrom
wenlongbrother:users/wenlong/AddGrpcGracefulShutDown

Conversation

@wenlongbrother

@wenlongbrother wenlongbrother commented Nov 3, 2023

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add grpc gracful shutdown

Why are the changes needed?

Data Integrity: To ensure that any ongoing write operations or transactions are properly handled to prevent data corruption or loss.

Resource Cleanup: To release resources such as file handles, network connections, and memory to prevent resource leaks.

User Experience: To provide feedback to users, where possible, informing them that the program is shutting down, to avoid sudden service interruptions causing distress.

State Preservation: In some applications, it may be necessary to save the current state so that the next start can continue from the same point.

Dependency Service Coordination: If your service is a dependency for other services, a graceful shutdown can ensure dependent services are notified to avoid causing cascading failures.

Error Tracking and Logging: Recording sufficient information during the shutdown process is very helpful for subsequent error analysis and troubleshooting.

Compliance with Laws and Regulations: Some applications process sensitive data and need to ensure compliance with legal and regulatory requirements to prevent data breaches during the shutdown process.

In distributed systems and microservices architectures, graceful shutdown becomes particularly important, as the interactions between services are more complex, and improper shutdowns can trigger a range of issues. For example, if a database service shuts down abruptly without gracefully handling current operations, it could lead to data inconsistencies that affect the stability of the entire system.

Overall, graceful shutdown is about ensuring the robustness and reliability of systems, maintaining service quality, and protecting data security even when service termination is necessary.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

image image

@roryqi roryqi changed the title [type:feat]Add grpc graceful shut down [#1221] feat(rust): Add grpc graceful shut down Nov 3, 2023
@roryqi
roryqi requested a review from zuston November 3, 2023 02:01
@codecov-commenter

codecov-commenter commented Nov 3, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1292 (dc1ba10) into master (b47c3d4) will increase coverage by 0.90%.
Report is 3 commits behind head on master.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master    #1292      +/-   ##
============================================
+ Coverage     53.83%   54.74%   +0.90%     
  Complexity     2691     2691              
============================================
  Files           401      383      -18     
  Lines         23418    21096    -2322     
  Branches       1992     1992              
============================================
- Hits          12606    11548    -1058     
+ Misses        10036     8844    -1192     
+ Partials        776      704      -72     

see 28 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@zuston zuston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work! @wenlongbrother

Overall LGTM. left minor comments.

Comment thread rust/experimental/server/src/lib.rs Outdated
Comment thread rust/experimental/server/src/lib.rs Outdated
Comment thread rust/experimental/server/src/main.rs Outdated
Comment thread rust/experimental/server/src/main.rs Outdated
use signal_hook::{consts::TERM_SIGNALS, iterator::Signals};
use tokio::sync::oneshot::Sender;

pub fn wait_for_signal() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could be deleted.

@zuston

zuston commented Nov 3, 2023

Copy link
Copy Markdown
Member

BTW, please run the cargo fmt to format your code

@zuston zuston changed the title [#1221] feat(rust): Add grpc graceful shut down [#1221] feat(rust): Add grpc graceful shutdown Nov 3, 2023
@smallzhongfeng

Copy link
Copy Markdown
Contributor

BTW, please run the cargo fmt to format your code

Maybe we can add this cargo fmt to ci ?

@wenlongbrother

Copy link
Copy Markdown
Contributor Author

Hi @zuston , I push some new changes, can you take a look again, thank you for your review.

@wenlongbrother
wenlongbrother requested a review from zuston November 5, 2023 09:19
@zuston

zuston commented Nov 6, 2023

Copy link
Copy Markdown
Member

BTW, please run the cargo fmt to format your code

Maybe we can add this cargo fmt to ci ?

fmt check has been added into CI. but the formatting code for developer is not suitable.

@zuston
zuston merged commit 91a4fca into apache:master Nov 6, 2023
@zuston

zuston commented Nov 6, 2023

Copy link
Copy Markdown
Member

Thanks for your contribution! @wenlongbrother

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.

4 participants