Diffusion C API 6.13.0
Loading...
Searching...
No Matches
retry-strategy.h File Reference

Functions relating to initial session establishment retry strategy. More...

Typedefs

typedef struct DIFFUSION_RETRY_STRATEGY_T DIFFUSION_RETRY_STRATEGY_T
 An opaque diffusion session establishment retry strategy struct.

Functions

DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_create (uint32_t interval, uint32_t attempts, DIFFUSION_API_ERROR *api_error)
 Creates a new retry strategy.
DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_dup (DIFFUSION_RETRY_STRATEGY_T *strategy)
 Duplicates a retry strategy.
DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_no_retry ()
 Creates a new retry strategy that indicates that no retry is to be attempted.
DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_create_interval_only (uint32_t interval, DIFFUSION_API_ERROR *api_error)
 Creates a new retry strategy that will retry indefinitely at the specified interval.
DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_create_backoff (uint32_t initial_interval, uint32_t max_interval, uint32_t attempts, DIFFUSION_API_ERROR *api_error)
 Creates a retry strategy that uses a randomized, growing-window backoff.
void diffusion_retry_strategy_free (DIFFUSION_RETRY_STRATEGY_T *retry_strategy)
 Free a retry strategy.
uint32_t diffusion_retry_strategy_get_interval (DIFFUSION_RETRY_STRATEGY_T *retry_strategy)
 Returns the number of milliseconds between retries.
uint32_t diffusion_retry_strategy_get_attempts (DIFFUSION_RETRY_STRATEGY_T *retry_strategy)
 Returns the maximum number of retries to attempt.
uint32_t diffusion_retry_strategy_get_max_interval (DIFFUSION_RETRY_STRATEGY_T *retry_strategy)
 Returns the maximum delay window, in milliseconds, of a backoff retry strategy.

Detailed Description

Functions relating to initial session establishment retry strategy.

Function Documentation

◆ diffusion_retry_strategy_create()

DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_create ( uint32_t interval,
uint32_t attempts,
DIFFUSION_API_ERROR * api_error )

Creates a new retry strategy.

A retry strategy will be applied when an initial attempt to open a session fails with a transient exception.

A retry strategy will be applied when recovering by a DIFFUSION_RECOVERABLE_UPDATE_STREAM_T following a recoverable exception.

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

Parameters
intervalthe number of milliseconds before the first retry and between subsequent retries.
attemptsthe number of retry attempts.
api_errorpopulated on API error. Can be NULL.
Returns
The new retry strategy if the operation was successful, NULL otherwise. In this case, if a non-NULL api_error pointer has been provided, this will be populated with the error information and should be freed with diffusion_api_error_free.

◆ diffusion_retry_strategy_create_backoff()

DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_create_backoff ( uint32_t initial_interval,
uint32_t max_interval,
uint32_t attempts,
DIFFUSION_API_ERROR * api_error )

Creates a retry strategy that uses a randomized, growing-window backoff.

The delay before retry attempt n is a random value in the range [(n - 1) * initial_interval, n * initial_interval), capped so it never exceeds max_interval. Spreading retries over a growing window prevents many clients that failed at the same moment (for example, following a server restart) from retrying in lockstep.

A retry strategy created this way can be used anywhere a DIFFUSION_RETRY_STRATEGY_T is accepted: initial session establishment (diffusion_session_factory_initial_retry_strategy) and DIFFUSION_RECOVERABLE_UPDATE_STREAM_T recovery (diffusion_update_stream_builder_create_recoverable_update_stream).

Parameters
initial_intervalthe window size, in milliseconds, added per attempt. Must be >= 1.
max_intervalthe maximum delay window, in milliseconds. Must be >= initial_interval.
attemptsthe maximum number of retry attempts. Must be >= 1.
api_errorpopulated on API error. Can be NULL.
Returns
The new retry strategy if the operation was successful, NULL otherwise. In this case, if a non-NULL api_error pointer has been provided, this will be populated with the error information and should be freed with diffusion_api_error_free.
Since
6.13

◆ diffusion_retry_strategy_create_interval_only()

DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_create_interval_only ( uint32_t interval,
DIFFUSION_API_ERROR * api_error )

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.
api_errorpopulated on API error. Can be NULL.
Returns
The new retry strategy if the operation was successful, NULL otherwise. In this case, if a non-NULL api_error pointer has been provided, this will be populated with the error information and should be freed with diffusion_api_error_free.

◆ diffusion_retry_strategy_dup()

DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_dup ( DIFFUSION_RETRY_STRATEGY_T * strategy)

Duplicates a retry strategy.

Parameters
strategyThe retry strategy to bee duplicated
Returns
A duplicate retry strategy or NULL if received strategy is NULL or invalid.

◆ diffusion_retry_strategy_free()

void diffusion_retry_strategy_free ( DIFFUSION_RETRY_STRATEGY_T * retry_strategy)

Free a retry strategy.

Parameters
retry_strategythe retry strategy to be freed.

◆ diffusion_retry_strategy_get_attempts()

uint32_t diffusion_retry_strategy_get_attempts ( DIFFUSION_RETRY_STRATEGY_T * retry_strategy)

Returns the maximum number of retries to attempt.

Parameters
retry_strategythe retry strategy.
Returns
The maximum number of retries to attempt.

◆ diffusion_retry_strategy_get_interval()

uint32_t diffusion_retry_strategy_get_interval ( DIFFUSION_RETRY_STRATEGY_T * retry_strategy)

Returns the number of milliseconds between retries.

Parameters
retry_strategythe retry strategy.
Returns
The number of milliseconds between retries.

◆ diffusion_retry_strategy_get_max_interval()

uint32_t diffusion_retry_strategy_get_max_interval ( DIFFUSION_RETRY_STRATEGY_T * retry_strategy)

Returns the maximum delay window, in milliseconds, of a backoff retry strategy.

Parameters
retry_strategythe retry strategy.
Returns
The maximum delay window in milliseconds, or 0 if the strategy was not created with diffusion_retry_strategy_create_backoff.
Since
6.13

◆ diffusion_retry_strategy_no_retry()

DIFFUSION_RETRY_STRATEGY_T * diffusion_retry_strategy_no_retry ( )

Creates a new retry strategy that indicates that no retry is to be attempted.

Returns
The new retry strategy.