Class TimeoutOptions

Namespace
Kevlar
Assembly
Kevlar.dll

Configuration for a timeout strategy.

public sealed class TimeoutOptions
Inheritance
TimeoutOptions
Inherited Members

Remarks

TimeoutGenerator runs before the timeout timer is armed and overrides Timeout for that execution. When a timeout wins, OnTimeout runs after timer cleanup and restoration of the caller's cancellation token. Hooks that complete synchronously add no overhead and remain compatible with synchronous Execute. The strategy always awaits the delegate and translates only a direct OperationCanceledException into TimeoutExceededException. A blocking synchronous delegate that ignores cancellation cannot be timed out, and a wrapped cancellation exception surfaces unchanged.

Constructors

TimeoutOptions()

public TimeoutOptions()

Properties

Name

An optional low-cardinality name used by strategy telemetry.

public string? Name { get; set; }

Property Value

string

OnTimeout

Invoked and awaited when an execution is cancelled because it exceeded the timeout. Return default from a synchronous callback. The event context is valid only until the returned task completes.

public Func<TimeoutEvent, ValueTask>? OnTimeout { get; set; }

Property Value

Func<TimeoutEvent, ValueTask>

Timeout

The maximum time an execution may take. The default is 30 seconds.

public TimeSpan Timeout { get; set; }

Property Value

TimeSpan

TimeoutGenerator

Produces the timeout for each execution and is awaited before the timer is armed. The event carries the configured Timeout and execution context. The returned value must be positive and no greater than the runtime timer limit. Return new(timeout) from a synchronous generator. The event context is valid only until the returned task completes.

public Func<TimeoutEvent, ValueTask<TimeSpan>>? TimeoutGenerator { get; set; }

Property Value

Func<TimeoutEvent, ValueTask<TimeSpan>>