ThreadPoolBulkhead

Thread-pool-isolation bulkhead (JVM). Admitted calls run on a dedicated fixed-size thread pool of BulkheadConfig.maxConcurrentCalls threads, so slow or blocking calls can never consume threads outside the pool.

Must be closed to release its threads.

ThreadPoolBulkhead.create("payments", BulkheadConfig(maxConcurrentCalls = 8)).use { b ->
b.execute { blockingJdbcCall() }
}

Types

Link copied to clipboard
object Companion

Factory for ThreadPoolBulkhead.

Properties

Link copied to clipboard

The configuration of this bulkhead.

Functions

Link copied to clipboard
suspend fun activeCalls(): Int

Returns the current number of active calls.

Link copied to clipboard

Adds a listener for bulkhead events.

Link copied to clipboard

Adapts this bulkhead into a Policy.

Link copied to clipboard
open override fun close()

Shuts the thread pool down.

Link copied to clipboard
suspend fun <T> execute(block: suspend () -> T): T

Executes block on the dedicated pool; see DispatcherBulkhead.execute.

Link copied to clipboard
suspend fun <T> executeOrFallback(fallback: suspend () -> T, block: suspend () -> T): T

Like execute but runs fallback when rejected.

Link copied to clipboard

Returns a snapshot of the current statistics.

Link copied to clipboard
suspend fun <T> tryExecute(block: suspend () -> T): T?

Like execute but returns null when rejected.