or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

caching.mdcookies.mdforms-multipart.mdhttp-client.mdindex.mdinterceptors.mdnetworking.mdrequests-responses.mdsecurity.mdurls.mdwebsockets.md

networking.mddocs/

0

# Connection Management

1

2

Connection pooling, dispatching, and network configuration for optimal performance.

3

4

## ConnectionPool

5

6

Manages HTTP and HTTPS connections for reuse to reduce latency.

7

8

```kotlin { .api }

9

class ConnectionPool(

10

maxIdleConnections: Int = 5,

11

keepAliveDuration: Long = 5,

12

timeUnit: TimeUnit = TimeUnit.MINUTES

13

) {

14

constructor(maxIdleConnections: Int, keepAliveDuration: Duration)

15

16

fun idleConnectionCount(): Int

17

fun connectionCount(): Int

18

fun evictAll()

19

}

20

```

21

22

## Dispatcher

23

24

Policy for request execution, including maximum concurrent requests.

25

26

```kotlin { .api }

27

class Dispatcher {

28

constructor()

29

constructor(executorService: ExecutorService)

30

31

var maxRequests: Int

32

var maxRequestsPerHost: Int

33

var idleCallback: Runnable?

34

val executorService: ExecutorService

35

36

fun cancelAll()

37

fun runningCallsCount(): Int

38

fun queuedCallsCount(): Int

39

fun runningCalls(): List<Call>

40

fun queuedCalls(): List<Call>

41

}

42

```