TCP/TLS connection pooling for Eio
1(** Cmdliner terms for connection pool configuration *)
2
3open Cmdliner
4
5let max_connections_per_endpoint =
6 let doc = "Maximum concurrent connections per endpoint." in
7 Arg.(value & opt int 10 & info ["max-connections-per-endpoint"] ~doc ~docv:"NUM")
8
9let max_idle_time =
10 let doc = "Maximum time a connection can sit idle in seconds." in
11 Arg.(value & opt float 60.0 & info ["max-idle-time"] ~doc ~docv:"SECONDS")
12
13let max_connection_lifetime =
14 let doc = "Maximum connection age in seconds." in
15 Arg.(value & opt float 300.0 & info ["max-connection-lifetime"] ~doc ~docv:"SECONDS")
16
17let max_connection_uses =
18 let doc = "Maximum times a connection can be reused (omit for unlimited)." in
19 Arg.(value & opt (some int) None & info ["max-connection-uses"] ~doc ~docv:"NUM")
20
21let connect_timeout =
22 let doc = "Connection timeout in seconds." in
23 Arg.(value & opt float 10.0 & info ["connect-timeout"] ~doc ~docv:"SECONDS")
24
25let connect_retry_count =
26 let doc = "Number of connection retry attempts." in
27 Arg.(value & opt int 3 & info ["connect-retry-count"] ~doc ~docv:"NUM")
28
29let connect_retry_delay =
30 let doc = "Initial retry delay in seconds (with exponential backoff)." in
31 Arg.(value & opt float 0.1 & info ["connect-retry-delay"] ~doc ~docv:"SECONDS")
32
33let config =
34 let make max_conn max_idle max_lifetime max_uses timeout retry_count retry_delay =
35 Config.make
36 ~max_connections_per_endpoint:max_conn
37 ~max_idle_time:max_idle
38 ~max_connection_lifetime:max_lifetime
39 ?max_connection_uses:max_uses
40 ~connect_timeout:timeout
41 ~connect_retry_count:retry_count
42 ~connect_retry_delay:retry_delay
43 ()
44 in
45 Term.(const make
46 $ max_connections_per_endpoint
47 $ max_idle_time
48 $ max_connection_lifetime
49 $ max_connection_uses
50 $ connect_timeout
51 $ connect_retry_count
52 $ connect_retry_delay)