Closed YHM404 closed 1 month ago
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.
This change is now available via https://github.com/cloudflare/pingora/commit/42b02241295a3a89bf44014aa991c88fa9e86e1f. Thanks for the contribution.
Motivation: In the current implementation of
ServerApp
trait (name the trait if possible), we have a synchronous methodcleanup
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 theServerApp
trait. This method is intended to asynchronously clean up resources, complementing the existingcleanup
method. Compatibility Considerations: To ensure backward compatibility and minimize disruption, the existingcleanup
method remains unchanged. Users can choose between cleanup for synchronous operations andasync_cleanup
for asynchronous operations, depending on their use case.