feat(layers/timeout): refactor timeout logic to be internal to the layer #7179
+10
−186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a complete refactor of the TimeoutLayer to address the architectural feedback from my previous attempt in #7176.
The Problem: My previous PR attempted to add timeout parameters to the operation arguments (ops), which leaked layer logic into the core.
The Solution: This version uses the Decorator pattern to wrap the futures directly within the TimeoutAccessor and TimeoutWrapper.
Key Changes:
Encapsulation: All tokio::time::timeout logic is now internal to the layer.
Zero Core Changes: No modifications were made to opendal_core::raw::ops.
Standardized Errors: Timeout errors now include duration context and are marked as temporary to support retry layers.
Verified: Included unit tests to confirm that operation timeouts trigger correctly.
I would appreciate a fresh review of this approach.