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() ?
11/25/2019, 4:50 PM
I'm not familiar with bulkhead but if you want to limit the threads used to handle the work then a FixedThreadPool would be the way to go imo
11/25/2019, 4:55 PM
I want extra work to be rejected when the thread pool is empty (after queueing for a thread to run on with a configurable timeout)
11/25/2019, 4:57 PM
You...want work to be thrown away when your thread pool has no work to do?
11/25/2019, 5:49 PM
Other way around. Sounds like they want work to be thrown away when they don't have any open threads to do it.
11/25/2019, 6:57 PM
I agree that's likely the intention, but I can't assume, so that's why I asked
11/26/2019, 1:03 AM
I would use a number of coroutines equal to the number of threads you want, with a shared Channel of tasks that has a maximum capacity. Then offer tasks to the channel and loop it on the workers.
Schedule it all on the default dispatcher
11/26/2019, 5:55 AM
I think in coroutines you would rely on normal backpressure and use a timeout to detect too much work