Repository navigation
Conversation
Motivation: Let a direct HTTP/2 client notify the peer when it stops opening requests while allowing existing responses to finish. Modification: Add a default-off option for normal request-source completion. Reuse the existing drain timeout and keep the released client settings constructor, copy and product layout by storing the opt-in in the existing internal settings slot. Result: An opted-in direct connection signals graceful close and continues draining. Default, managed and pooled behavior is unchanged. Settings copies keep the option without changing old JVM signatures. References: RFC 9113 section 6.8.
927b283 to
beec719
Compare
pjfanning
left a comment
There was a problem hiding this comment.
The engine change looks right to me: the GOAWAY goes through the control-frame queue after any request HEADERS, in-flight streams still drain, and nothing changes with the option off. Two points on the code:
The setting is stored by wrapping internalSettings. GracefulGoAwayEnabled(delegate) wraps the slot, sendGoAwayOnGracefulClose is true when the slot holds the wrapper, and withInternalSettings re-wraps to keep the flag. This is the same concern as on #981, #1556, #1589 and now #1664, each of which uses the slot in a different way:
settings.internalSettingsno longer returns what was passed towithInternalSettingsonce the flag is on, so any reader has to know to unwrap it.copy(internalSettings = Some(x))on the impl silently drops the flag.- It does not compose with the other PRs: each would overwrite, or fail to recognise, the others' value in the slot.
I would rather this were a real field on Http2ClientSettingsImpl, and that we settle one approach for all of these PRs.
withoutClientGoAway has no test. It is the only thing that stops managedPersistentHttp2* from sending the GOAWAY when the wrapper completes its inner request source on retirement or downstream cancellation, and removing the two withoutClientGoAway. prefixes would leave every test green. Could you add a case with the option on and a managed connection, asserting that no GOAWAY is sent on cancel or retire?
Smaller: a request source that fails rather than completes is described as not sending a GOAWAY, and by my reading that is what happens (onUpstreamFailure -> failStage), but there is no user.requestOut.sendError(...) case to pin it.
Motivation
A direct HTTP/2 client currently closes the connection after its request source finishes and outstanding responses drain. Some peers can shut down more cleanly when the client first signals that it is closing the HTTP/2 connection.
Modification
pekko.http.client.http2.send-goaway-on-graceful-close, off by default, with Scala and Java settings access.GOAWAY(NO_ERROR)on normal request-source completion for direct connections. The last-stream ID is0because this client does not accept server push. Preserve the existing response drain and completion timeout.Result
Direct HTTP/2 clients can opt in to a graceful protocol close without changing the default or dropping outstanding responses. The existing concrete client settings retain their 21-field binary shape.
Tests
copy,apply, and extractor. The compiled public settings consumer works unchanged.References