Scoop API

scoop:scoop.http.client:0.1.0

src/pool/options.scoop

Selected production source · src/pool/options.scoop

1package scoop.http.client
3import scoop.time.Duration
5/**
6 * Positive connection/HTTP2 stream capacities plus idle and optional maximum connection lifetimes.
7 */
8public class HttpConnectionPoolOptions internal constructor(
9 /**
10 * Maximum connections pooled or being established for one origin.
11 */
12 public val maxConnectionsPerOrigin: Long = 8L,
13 /**
14 * Maximum connections across the client.
15 */
16 public val maxConnections: Long = 64L,
17 /**
18 * Local concurrent-stream cap per HTTP/2 connection, also constrained by peer settings.
19 */
20 public val maxStreamsPerHttp2: Long = 100L,
21 /**
22 * How long an unused connection remains reusable.
23 */
24 public val idleTimeout: Duration = Duration.seconds(60L),
25 /**
26 * Optional maximum connection age before retirement; existing active work follows normal
27 * draining rules.
28 */
29 public val maxLifetime: Duration? = None
30) {
31 init {
32 if (maxConnectionsPerOrigin <= 0L || maxConnections <= 0L || maxStreamsPerHttp2 <= 0L)
33 throw IllegalArgumentException(
34 Some("HTTP connection and stream limits must be positive")
35 )
36 if (
37 idleTimeout <
38 Duration.ZERO ||
39 (clientPresent(maxLifetime) && maxLifetime!! <= Duration.ZERO)
40 )
41 throw IllegalArgumentException(Some("invalid HTTP connection lifetime"))
42 }