if I want to implement the bulkhead pattern in kot...
# server
r
if I want to implement the bulkhead pattern in kotlin, with an old-fashioned blocking http client (OkHttp/feign), what is an idiomatic way to do it in kotlin? A channel with a coroutinecontext backed by a fixed threadpool and ThreadPoolExecutor.AbortPolicy() ?
e
The Apache HTTP client, and by extension the Ktor client, has options for connection pooling on both a total concurrent connections and concurrent connections per-route basis. If you’re using the Ktor client, you can just configure the underlying Apache HttpClient engine the same way as these instructions: https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html …via the
customizeClient
block in its config: https://ktor.io/clients/http-client/engines.html#apache Then, whenever you make HTTP requests with that client it will automatically ensure your entire thread pool isn’t being consumed (in a bulkhead pattern-like way) and do keep-alive for you for subsequent requests