H2_conpool_handlerHTTP/2 Protocol Handler for Conpool.
This module provides a protocol handler that enables HTTP/2 connection multiplexing through Conpool's typed pool API. It manages H2_client instances and supports concurrent stream multiplexing.
Key features:
val src : Logs.srctype h2_state = {client : H2_client.t;The underlying HTTP/2 client.
*)flow : Conpool.Config.connection_flow;The connection flow (needed for H2 operations).
*)sw : Eio.Switch.t;Connection-lifetime switch for the reader fiber.
*)mutable reader_started : bool;Whether the background reader fiber has been started.
*)mutable goaway_received : bool;Whether GOAWAY has been received from peer.
*)mutable last_goaway_stream : int32;Last stream ID from GOAWAY (streams > this may be retried).
*)mutable last_goaway_code : H2_frame.error_code;Error code from the last GOAWAY frame.
*)mutable max_concurrent_streams : int;Cached max_concurrent_streams from peer settings.
*)}HTTP/2 connection state managed by Conpool. This wraps H2_client.t with additional tracking for stream management.
val init_state :
sw:Eio.Switch.t ->
flow:[ `Close | `Flow | `R | `Shutdown | `W ] Eio.Resource.t ->
tls_epoch:'a ->
h2_stateInitialize HTTP/2 state for a new connection. Performs the HTTP/2 handshake and extracts peer settings. The sw parameter is a connection-lifetime switch that will be used to spawn the background reader fiber when on_acquire is called.
val on_acquire : h2_state -> unitCalled when a connection is acquired from the pool. Starts the background reader fiber on first acquisition.
Called when a connection is released back to the pool. For HTTP/2, this is a no-op since the reader keeps running.
val is_healthy : h2_state -> boolCheck if the HTTP/2 connection is still healthy.
val on_close : h2_state -> unitCleanup when connection is destroyed.
val access_mode : h2_state -> Conpool.Config.access_modeGet access mode for this connection. HTTP/2 supports multiplexing: multiple concurrent streams per connection.
val h2_protocol : h2_state Conpool.Config.protocol_configThe protocol configuration for HTTP/2 connections.
val request :
state:h2_state ->
uri:Uri.t ->
headers:Headers.t ->
?body:Body.t ->
method_:Method.t ->
auto_decompress:bool ->
unit ->
(H2_adapter.response, Error.error) resultMake an HTTP/2 request using the pooled connection state.
Uses the concurrent request path with the connection-lifetime reader fiber. Multiple requests can be made concurrently on the same connection.