withTimeLimitOrDefault

suspend fun <T> withTimeLimitOrDefault(timeout: Duration, default: T, block: suspend () -> T): T(source)

Extension function to add timeout with fallback to any suspend function.

Example usage:

val result = withTimeLimitOrDefault(5.seconds, defaultValue = emptyList()) {
slowOperation()
}