pingora
pingora copied to clipboard
Add `async_cleanup()` method to `ServerApp` trait
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.
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.