feat(http2): add an optional keep-alive reuse timeout observer - #4187
Open
jiahaoliang wants to merge 4 commits into
Open
feat(http2): add an optional keep-alive reuse timeout observer#4187jiahaoliang wants to merge 4 commits into
jiahaoliang wants to merge 4 commits into
Conversation
Notify connection pools without shortening the hard timeout for active streams. Keep the existing h2 dependency range and expose the observer on the H2 client API. Cover timer wakeups and final-configuration validation.
Author
|
Use my own word to summary: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fix: #4186
Connection pools may need to stop assigning new requests to an unresponsive H2 connection while retaining a longer keep-alive timeout for its existing streams. This PR implements the Hyper portion of the shared reuse-timeout proposal: a connection-specific notification for that policy without shortening the existing hard timeout. The companion hyper-util PR handles pool retirement.
The HTTP/2 client builder gains
keep_alive_reuse_timeout(Option<Duration>)andkeep_alive_observer(...), withKeepAliveObserverexposed underhyper::client::conn::http2.The new timeout defaults to disabled. When enabled, an independent timer follows the existing keep-alive PING timeout phase. If the ACK is still pending when that timer expires, the observer is taken and invoked once after releasing the PING state lock. The original hard timer remains registered with its original deadline.
Behavioral details:
Validation covers timer wakeup without IO, preservation of the hard deadline, one-shot observer consumption, and configuration boundaries. Companion hyper-util tests exercise pool retirement and completion of existing response headers and streaming bodies over paused duplex IO. Review CI passed 124 Hyper unit tests, the client/server feature checks, and documentation and formatting checks. The dependency resolver selected h2 0.4.19 with the unchanged upstream version range.
This is intended as a narrow notification API; the connection pool owns retirement and replacement. API naming and placement are open to maintainer feedback.