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

Add async_cleanup() method to ServerApp trait #193

Closed
wants to merge 2 commits into from

Conversation

YHM404
Copy link
Contributor

@YHM404 YHM404 commented Apr 9, 2024

Motivation:
In the current implementation of ServerApp trait (name the trait if possible), we have a synchronous method cleanup designed to clean up resources when a service is stopped. However, as our application evolves and embraces more asynchronous operations, the need for an asynchronous cleanup method has become apparent. This addition will allow for non-blocking resource cleanup, aligning with the asynchronous nature of our other operations.

Changes:
Added async fn async_cleanup(): Introduced a new asynchronous function, async_cleanup, to the ServerApp trait. This method is intended to asynchronously clean up resources, complementing the existing cleanup method.
Compatibility Considerations: To ensure backward compatibility and minimize disruption, the existing cleanup method remains unchanged. Users can choose between cleanup for synchronous operations and async_cleanup for asynchronous operations, depending on their use case.

pingora-core/src/apps/mod.rs Outdated Show resolved Hide resolved
@andrewhavck andrewhavck added the enhancement New feature or request label Apr 12, 2024
Copy link
Contributor

@drcaramelsyrup drcaramelsyrup left a comment

Choose a reason for hiding this comment

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

Discussing internally: though it would be a breaking change, we thought it would be preferable to make the existing cleanup() an async function for simplicity, especially while we are still in v0. Does that resolve your issue, and would you be able to make that change?

@YHM404
Copy link
Contributor Author

YHM404 commented Apr 20, 2024

Discussing internally: though it would be a breaking change, we thought it would be preferable to make the existing cleanup() an async function for simplicity, especially while we are still in v0. Does that resolve your issue, and would you be able to make that change?

I have made the corresponding modifications to the PR. This should resolve my issue. Thank you for your reply.

Copy link
Contributor

@drcaramelsyrup drcaramelsyrup left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! I will sync this up internally.

@drcaramelsyrup drcaramelsyrup added the Accepted This change is accepted by us and merged to our internal repo label Apr 26, 2024
eaufavor pushed a commit that referenced this pull request May 10, 2024
---
Refactor cleanup functions to use async/await

Includes-commit: 3cd52fe
Includes-commit: 58946a8
Replicated-from: #193
eaufavor pushed a commit that referenced this pull request May 10, 2024
---
Refactor cleanup functions to use async/await

Includes-commit: 3cd52fe
Includes-commit: 58946a8
Replicated-from: #193
@eaufavor
Copy link
Member

This change is now available via 42b0224. Thanks for the contribution.

@eaufavor eaufavor closed this May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted This change is accepted by us and merged to our internal repo enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants