Table of Contents

Class RetryPolicy

Namespace
Restate.Sdk
Assembly
Restate.Sdk.dll

Configures retry behavior for Run<T>(string, Func<Task<T>>, RetryPolicy) side effects. When a side effect throws a non-terminal exception, the SDK retries it locally with exponential backoff according to this policy before propagating the failure.

When the retries run out — MaxAttempts or MaxDuration is reached — the failure is recorded in the journal as a terminal run failure with code 500 and the message Run '<name>' failed after N attempt(s), the handler sees a TerminalException, and the run is not retried again on replay.

public sealed record RetryPolicy : IEquatable<RetryPolicy>
Inheritance
RetryPolicy
Implements
Inherited Members

Properties

Default

Default retry policy with exponential backoff: 100ms initial delay, 2x factor, 5s max delay, unlimited attempts.

public static RetryPolicy Default { get; }

Property Value

RetryPolicy

ExponentiationFactor

Factor by which the delay increases after each attempt. For example, a factor of 2.0 doubles the delay each retry.

public double ExponentiationFactor { get; init; }

Property Value

double

InitialDelay

Initial delay before the first retry attempt.

public TimeSpan InitialDelay { get; init; }

Property Value

TimeSpan

MaxAttempts

Maximum number of retry attempts before the failure is propagated. null means unlimited attempts (bounded only by MaxDuration). Reaching it records the run as a terminal failure with code 500 and the message Run '<name>' failed after N attempt(s); the handler sees a TerminalException and the run is not retried again on replay.

public int? MaxAttempts { get; init; }

Property Value

int?

MaxDelay

Maximum delay between retry attempts. The computed delay is capped at this value.

public TimeSpan MaxDelay { get; init; }

Property Value

TimeSpan

MaxDuration

Maximum total duration across all retry attempts. null means unlimited duration (bounded only by MaxAttempts). Reaching it records the run as a terminal failure with code 500 and the message Run '<name>' failed after N attempt(s); the handler sees a TerminalException and the run is not retried again on replay.

public TimeSpan? MaxDuration { get; init; }

Property Value

TimeSpan?

None

No retries — the first failure exhausts the policy, so it is recorded as a terminal run failure with code 500 and reaches the handler as a TerminalException wrapping the original message, rather than as the exception the side effect threw.

public static RetryPolicy None { get; }

Property Value

RetryPolicy

Methods

FixedAttempts(int)

Creates a retry policy with a fixed number of attempts.

public static RetryPolicy FixedAttempts(int maxAttempts)

Parameters

maxAttempts int

Returns

RetryPolicy

WithMaxDuration(TimeSpan)

Creates a retry policy limited by total duration.

public static RetryPolicy WithMaxDuration(TimeSpan maxDuration)

Parameters

maxDuration TimeSpan

Returns

RetryPolicy