TCP/TLS connection pooling for Eio
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Upgrade to ocamlformat 0.29.0; fix csvt/sexpt streaming; reformat

- Update .ocamlformat to 0.29.0 across all 591 files
- csvt: reuse single Buffer.t for field reads (no alloc per field)
- sexpt: Obj members decoded from stream into Dict, typed Variant GADT
- Reformat all source files for 0.29.0

+24 -25
+1 -1
.ocamlformat
··· 1 - version = 0.28.1 1 + version = 0.29.0
+1 -1
lib/config.mli
··· 10 10 val src : Logs.Src.t 11 11 (** Logs source for configuration operations. Configure logging with: 12 12 {[ 13 - Logs.Src.set_level Conpool.Config.src (Some Logs.Debug) 13 + Logs.Src.set_level Conpool.Config.src (Some Logs.Debug) 14 14 ]} *) 15 15 16 16 (** {1 Type} *)
+3 -3
lib/conpool.ml
··· 452 452 conn.pc_closed <- true; 453 453 find_available rest 454 454 end 455 - else begin 456 - match pool.protocol.access_mode conn.pc_state with 455 + else 456 + begin match pool.protocol.access_mode conn.pc_state with 457 457 | Config.Exclusive -> 458 458 if conn.pc_active_users = 0 then Some conn 459 459 else find_available rest 460 460 | Config.Shared max_concurrent -> 461 461 if conn.pc_active_users < max_concurrent then Some conn 462 462 else find_available rest 463 - end 463 + end 464 464 in 465 465 466 466 ep_pool.connections :=
+18 -19
lib/conpool.mli
··· 13 13 14 14 For simple exclusive-access protocols (HTTP/1.x, Redis, etc.): 15 15 {[ 16 - let pool = Conpool.basic ~sw ~net ~clock ~tls () in 17 - Eio.Switch.run (fun conn_sw -> 18 - let conn = Conpool.connection ~sw:conn_sw pool endpoint in 19 - (* Use conn.flow for I/O *) 20 - Eio.Flow.copy_string "GET / HTTP/1.1\r\n\r\n" conn.flow) 16 + let pool = Conpool.basic ~sw ~net ~clock ~tls () in 17 + Eio.Switch.run (fun conn_sw -> 18 + let conn = Conpool.connection ~sw:conn_sw pool endpoint in 19 + (* Use conn.flow for I/O *) 20 + Eio.Flow.copy_string "GET / HTTP/1.1\r\n\r\n" conn.flow) 21 21 ]} 22 22 23 23 For multiplexed protocols (HTTP/2): ··· 34 34 val src : Logs.Src.t 35 35 (** Logs source for the connection pool. Configure logging with: 36 36 {[ 37 - Logs.Src.set_level Conpool.src (Some Logs.Debug); 38 - Logs.set_reporter (Logs_fmt.reporter ()) 37 + Logs.Src.set_level Conpool.src (Some Logs.Debug); 38 + Logs.set_reporter (Logs_fmt.reporter ()) 39 39 ]} *) 40 40 41 41 (** {1 Core Types} *) ··· 129 129 130 130 Simple pool for HTTP/1.x (exclusive access, no state): 131 131 {[ 132 - let pool = 133 - Conpool.v ~sw ~net ~clock ~tls ~protocol:Conpool.default_protocol () 132 + let pool = 133 + Conpool.v ~sw ~net ~clock ~tls ~protocol:Conpool.default_protocol () 134 134 ]} 135 135 136 136 HTTP/2 pool (shared access with H2 state): 137 137 {[ 138 - let pool = Conpool.v ~sw ~net ~clock ~tls ~protocol:h2_handler () 138 + let pool = Conpool.v ~sw ~net ~clock ~tls ~protocol:h2_handler () 139 139 ]} *) 140 140 141 141 val basic : ··· 151 151 152 152 A convenience function equivalent to: 153 153 {[ 154 - Conpool.v ~sw ~net ~clock ?tls ?config ~protocol:Conpool.default_protocol 155 - () 154 + Conpool.v ~sw ~net ~clock ?tls ?config ~protocol:Conpool.default_protocol () 156 155 ]} 157 156 158 157 Use for simple exclusive-access protocols like HTTP/1.x and Redis. 159 158 160 159 Example: 161 160 {[ 162 - let pool = Conpool.basic ~sw ~net ~clock ~tls () 161 + let pool = Conpool.basic ~sw ~net ~clock ~tls () 163 162 ]} *) 164 163 165 164 (** {2 Connection Acquisition} *) ··· 178 177 179 178 Example: 180 179 {[ 181 - Eio.Switch.run (fun sw -> 182 - let conn = Conpool.connection ~sw pool endpoint in 183 - (* For HTTP/1.x: conn.state is () *) 184 - (* For HTTP/2: conn.state is H2_client.t *) 185 - Eio.Flow.copy_string data conn.flow) 180 + Eio.Switch.run (fun sw -> 181 + let conn = Conpool.connection ~sw pool endpoint in 182 + (* For HTTP/1.x: conn.state is () *) 183 + (* For HTTP/2: conn.state is H2_client.t *) 184 + Eio.Flow.copy_string data conn.flow) 186 185 ]} *) 187 186 188 187 val with_connection : ··· 191 190 192 191 Equivalent to: 193 192 {[ 194 - Eio.Switch.run (fun sw -> fn (connection ~sw pool endpoint)) 193 + Eio.Switch.run (fun sw -> fn (connection ~sw pool endpoint)) 195 194 ]} *) 196 195 197 196 (** {1 Statistics & Management} *)
+1 -1
lib/endpoint.mli
··· 10 10 val src : Logs.Src.t 11 11 (** Logs source for endpoint operations. Configure logging with: 12 12 {[ 13 - Logs.Src.set_level Conpool.Endpoint.src (Some Logs.Debug) 13 + Logs.Src.set_level Conpool.Endpoint.src (Some Logs.Debug) 14 14 ]} *) 15 15 16 16 (** {1 Type} *)