DefaultTimeoutPolicy

A TimeoutPolicy that executes a given block of code within a specified time limit. If the execution time exceeds the configured timeout, it triggers a timeout event and re-throws a TimeoutCancellationException.

This implementation uses Kotlin Coroutines' withTimeout to enforce the time limit.

Parameters

config

The TimeoutConfig containing the timeout duration and the action to perform on timeout.

Constructors

Link copied to clipboard
constructor(config: TimeoutConfig)

Functions

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

Executes block with a time limit. If execution exceeds the configured timeout, it is cancelled.