Temporal Docs PHP SDK API Version 2.21 (latest release) Release notes

Documentation

MethodRetry extends RetryOptions
in package

FinalYes

Specifies a retry policy for a workflow or activity method. This annotation applies only to activity or workflow interface methods. For workflows used for child workflow retries and for workflows started via {@see \Temporal\Client\WorkflowClient}. Not required. When not used either retries don't happen or they are configured through correspondent options. If {@see RetryOptions} are present on {@see ActivityOptions}, {@see ChildWorkflowOptions} or {@see \Temporal\Client\WorkflowOptions} the fields that are not default take precedence over parameters of this attribute/annotation.

Tags
psalm-import-type

DateIntervalValue from DateInterval

ExceptionsList from RetryOptions

Annotation
NamedArgumentConstructor
Target

({ "METHOD" })

Attributes
#[Attribute]
\Attribute::TARGET_METHOD
#[NamedArgumentConstructor]

Table of Contents

Constants

DEFAULT_BACKOFF_COEFFICIENT  : float = 2.0
DEFAULT_INITIAL_INTERVAL  : null = null
DEFAULT_MAXIMUM_ATTEMPTS  : int<0, max> = 0
DEFAULT_MAXIMUM_INTERVAL  : null = null
DEFAULT_NON_RETRYABLE_EXCEPTIONS  : mixed = []

Properties

$backoffCoefficient  : float
Coefficient used to calculate the next retry backoff interval. The next retry interval is previous interval multiplied by this coefficient.
$initialInterval  : DateInterval|null
Backoff interval for the first retry. If {@see RetryOptions::$backoffCoefficient} is 1.0 then it is used for all retries.
$maximumAttempts  : int<0, max>
Maximum number of attempts. When exceeded the retries stop even if not expired yet. If not set or set to 0, it means unlimited, and rely on activity {@see ActivityOptions::$scheduleToCloseTimeout} to stop.
$maximumInterval  : DateInterval|null
Maximum backoff interval between retries. Exponential backoff leads to interval increase. This value is the cap of the interval.
$nonRetryableExceptions  : ExceptionsList
Non-Retriable errors. This is optional. Temporal server will stop retry if error type matches this list.

Methods

__construct()  : mixed
mergeWith()  : self
toWorkflowRetryPolicy()  : RetryPolicy
Converts DTO to protobuf object
withBackoffCoefficient()  : static
withInitialInterval()  : static
withMaximumAttempts()  : static
withMaximumInterval()  : static
withNonRetryableExceptions()  : static

Constants

DEFAULT_BACKOFF_COEFFICIENT

public float DEFAULT_BACKOFF_COEFFICIENT = 2.0

DEFAULT_INITIAL_INTERVAL

public null DEFAULT_INITIAL_INTERVAL = null

DEFAULT_MAXIMUM_ATTEMPTS

public int<0, max> DEFAULT_MAXIMUM_ATTEMPTS = 0

DEFAULT_MAXIMUM_INTERVAL

public null DEFAULT_MAXIMUM_INTERVAL = null

DEFAULT_NON_RETRYABLE_EXCEPTIONS

public mixed DEFAULT_NON_RETRYABLE_EXCEPTIONS = []
Tags
psalm-var

ExceptionsList

Properties

$backoffCoefficient

Coefficient used to calculate the next retry backoff interval. The next retry interval is previous interval multiplied by this coefficient.

public float $backoffCoefficient = self::DEFAULT_BACKOFF_COEFFICIENT

Note: Must be greater than 1.0

Attributes
#[Marshal]
$name: 'backoff_coefficient'
#[Marshal]
$name: 'BackoffCoefficient'

$initialInterval

Backoff interval for the first retry. If {@see RetryOptions::$backoffCoefficient} is 1.0 then it is used for all retries.

public DateInterval|null $initialInterval = self::DEFAULT_INITIAL_INTERVAL
Attributes
#[Marshal]
$name: 'initial_interval'
$type: \Temporal\Internal\Marshaller\Type\DurationJsonType::class
$nullable: true
#[Marshal]
$name: 'InitialInterval'
$type: \Temporal\Internal\Marshaller\Type\DurationJsonType::class
$nullable: true

$maximumAttempts

Maximum number of attempts. When exceeded the retries stop even if not expired yet. If not set or set to 0, it means unlimited, and rely on activity {@see ActivityOptions::$scheduleToCloseTimeout} to stop.

public int<0, max> $maximumAttempts = self::DEFAULT_MAXIMUM_ATTEMPTS
Attributes
#[Marshal]
$name: 'maximum_attempts'
#[Marshal]
$name: 'MaximumAttempts'

$maximumInterval

Maximum backoff interval between retries. Exponential backoff leads to interval increase. This value is the cap of the interval.

public DateInterval|null $maximumInterval = self::DEFAULT_MAXIMUM_INTERVAL

Default is 100x of $initialInterval.

Attributes
#[Marshal]
$name: 'maximum_interval'
$type: \Temporal\Internal\Marshaller\Type\DurationJsonType::class
$nullable: true
#[Marshal]
$name: 'MaximumInterval'
$type: \Temporal\Internal\Marshaller\Type\DurationJsonType::class
$nullable: true

$nonRetryableExceptions

Non-Retriable errors. This is optional. Temporal server will stop retry if error type matches this list.

public ExceptionsList $nonRetryableExceptions = self::DEFAULT_NON_RETRYABLE_EXCEPTIONS
Attributes
#[Marshal]
$name: 'non_retryable_error_types'
#[Marshal]
$name: 'NonRetryableErrorTypes'

Methods

__construct()

public __construct([DateIntervalValue|null $initialInterval = self::DEFAULT_INITIAL_INTERVAL ][, DateIntervalValue|null $maximumInterval = self::DEFAULT_MAXIMUM_INTERVAL ][, int<0, max> $maximumAttempts = self::DEFAULT_MAXIMUM_ATTEMPTS ][, float $backoffCoefficient = self::DEFAULT_BACKOFF_COEFFICIENT ][, ExceptionsList $nonRetryableExceptions = self::DEFAULT_NON_RETRYABLE_EXCEPTIONS ]) : mixed
Parameters
$initialInterval : DateIntervalValue|null = self::DEFAULT_INITIAL_INTERVAL
$maximumInterval : DateIntervalValue|null = self::DEFAULT_MAXIMUM_INTERVAL
$maximumAttempts : int<0, max> = self::DEFAULT_MAXIMUM_ATTEMPTS
$backoffCoefficient : float = self::DEFAULT_BACKOFF_COEFFICIENT
$nonRetryableExceptions : ExceptionsList = self::DEFAULT_NON_RETRYABLE_EXCEPTIONS

toWorkflowRetryPolicy()

Converts DTO to protobuf object

public toWorkflowRetryPolicy() : RetryPolicy
Tags
psalm-suppress

ImpureMethodCall

Return values
RetryPolicy

withBackoffCoefficient()

public withBackoffCoefficient(float $coefficient) : static
Parameters
$coefficient : float
Tags
psalm-suppress

ImpureMethodCall

Attributes
#[Pure]
Return values
static

withInitialInterval()

public withInitialInterval(mixed $interval) : static
Parameters
$interval : mixed

parseable string, null, int|float in seconds, DateInterval, or Duration

Tags
psalm-suppress

ImpureMethodCall

Attributes
#[Pure]
Return values
static

withMaximumAttempts()

public withMaximumAttempts(int<0, max> $attempts) : static
Parameters
$attempts : int<0, max>
Tags
psalm-suppress

ImpureMethodCall

Attributes
#[Pure]
Return values
static

withMaximumInterval()

public withMaximumInterval(mixed $interval) : static
Parameters
$interval : mixed

parseable string, null, int|float in seconds, DateInterval, or Duration

Tags
psalm-suppress

ImpureMethodCall

Attributes
#[Pure]
Return values
static

withNonRetryableExceptions()

public withNonRetryableExceptions(ExceptionsList $exceptions) : static
Parameters
$exceptions : ExceptionsList
Tags
psalm-suppress

ImpureMethodCall

Attributes
#[Pure]
Return values
static
On this page

Search results