Diffusion Apple API 6.13.0
Unified Client Library for iOS and OS X / macOS
Loading...
Searching...
No Matches
PTDiffusionRetryStrategy Class Reference

Introduction

Defines a retry strategy.

A retry strategy will be applied when an initial to attempt to open a session fails with a SessionEstablishmentTransientException, and can also be used to govern recovery attempts made by a PTDiffusionRecoverableUpdateStream.

The strategy is defined in terms of the number of milliseconds between retries and the maximum number of retries to attempt.

By default, every attempt waits the same, fixed interval. Supplying a PTDiffusionRetryBackoffCalculator allows this to be varied, for example to implement an exponential backoff, by calculating the interval for each attempt individually.

Since
6.9
Inheritance diagram for PTDiffusionRetryStrategy:

Class Methods

(instancetype) + NO_RETRY

Properties

NSUInteger interval
NSInteger attempts

Instance Methods

(instancetype) - initWithInterval:andAttempts:
(instancetype) - initWithInterval:andAttempts:backoff:
(NSUInteger) - intervalForAttempt:
(instancetype) - initWithInterval:

Method Documentation

◆ initWithInterval:

- (instancetype) initWithInterval: (const NSUInteger) interval

Creates a new retry strategy that will retry indefinitely at the specified interval.

Parameters
intervalthe number of milliseconds before the first retry and between subsequent retries
Returns
the new retry strategy
Since
6.9

◆ initWithInterval:andAttempts:

- (instancetype) initWithInterval: (const NSUInteger) interval
andAttempts: (const NSInteger) attempts 

Creates a new retry strategy object.

Parameters
intervalthe number of milliseconds before the first retry and between subsequent retries
attemptsthe number of retry attempts
Returns
the new retry strategy
Since
6.9

◆ initWithInterval:andAttempts:backoff:

- (instancetype) initWithInterval: (NSUInteger) interval
andAttempts: (NSInteger) attempts
backoff: (nullable PTDiffusionRetryBackoffCalculator) backoff 

Creates a new retry strategy object that varies the interval between retries according to the given backoff calculator.

Parameters
intervalthe base interval, in milliseconds, passed to backoff for it to calculate the actual interval to apply
attemptsthe number of retry attempts
backoffa block that calculates the interval, in milliseconds, to wait before making a given attempt. If nil, every attempt waits the fixed interval, equivalent to using initWithInterval:andAttempts:.
Returns
the new retry strategy
Since
6.13

◆ intervalForAttempt:

- (NSUInteger) intervalForAttempt: (NSUInteger) attempt

Calculates the interval, in milliseconds, to wait before making the given retry attempt.

If this strategy was created without a PTDiffusionRetryBackoffCalculator, this always returns interval, regardless of the attempt number.

Parameters
attemptthe attempt number for which the interval is being calculated. The first attempt is 1.
Returns
the interval, in milliseconds, to wait before making this attempt
Since
6.13

◆ NO_RETRY

+ (instancetype) NO_RETRY

The retry strategy that indicates that no retry is to be attempted.

Returns
The retry strategy indicating that no retry is to be attempted.

Property Documentation

◆ attempts

- (NSInteger) attempts
readnonatomicassign

The maximum number of retries to attempt

Since
6.9

◆ interval

- (NSUInteger) interval
readnonatomicassign

The number of milliseconds between retries

Since
6.9