AMPS C/C++ Client Class Reference AMPS C/C++ Client Version 5.3.5.6

Public Member Functions | List of all members
AMPS::ExponentialDelayStrategy Class Reference

ExponentialDelayStrategy is an implementation that exponentially "backs off" when reconnecting to the same server, with a maximum number of retries before it gives up entirely. More...

`#include <ReconnectDelayStrategyImpl.hpp>`

Inheritance diagram for AMPS::ExponentialDelayStrategy:

## Public Member Functions
| ExponentialDelayStrategy (unsigned int initialDelay_=200, unsigned int maximumDelay_=20 *1000, double backoffExponent_=2.0, unsigned int maximumRetryTime_=0, double jitter_=1.0)
| Constructs an exponential delay strategy, the default strategy for HAClient. More...
unsigned int | getConnectWaitDuration (const std::string &uri_)
| Returns the time that the client should delay before connecting to the given server URI. More...
void | reset (void)
| Reset the state of this reconnect delay. More...

## Detailed Description

ExponentialDelayStrategy is an implementation that exponentially "backs off" when reconnecting to the same server, with a maximum number of retries before it gives up entirely.

## Constructor & Destructor Documentation

## ◆ ExponentialDelayStrategy()

AMPS::ExponentialDelayStrategy::ExponentialDelayStrategy | ( | unsigned int | initialDelay_ = `200`,
|  | unsigned int | maximumDelay_ = `20 * 1000`,
|  | double | backoffExponent_ = `2.0`,
|  | unsigned int | maximumRetryTime_ = `0`,
|  | double | jitter_ = `1.0`
| ) |  |
| inline

Constructs an exponential delay strategy, the default strategy for HAClient.

Parameters

  initialDelay_ | The time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection attempt.
  maximumDelay_ | The maximum time to wait for any reconnect attempt (milliseconds). Exponential backoff will not exceed this maximum.
  backoffExponent_ | The exponent to use for calculating the next delay time. For example, if the initial time is 200ms and the exponent is 2.0, the next delay will be 400ms, then 800ms, etc.
  maximumRetryTime_ | The maximum time (milliseconds) to allow reconnect attempts to continue without a successful connection, before "giving up" and abandoning the connection attempt.
  jitter_ | The amount of 'jitter' to apply when calculating a delay time, measured in multiples of the initial delay. Jitter is used to reduce the number of simultaneous reconnects that may be issued from multiple clients.

## Member Function Documentation

## ◆ getConnectWaitDuration()

unsigned int AMPS::ExponentialDelayStrategy::getConnectWaitDuration | ( | const std::string & | uri_ | ) |
| inline virtual

Returns the time that the client should delay before connecting to the given server URI.

Parameters

  uri_ | The URI which the client plans to connect.

Returns
  The time, in milliseconds, which the client should delay before connecting to uri_.

Exceptions

  Any | exception thrown indicates no connection should be attempted; the client should in essence "give up."

Implements AMPS::ReconnectDelayStrategyImpl.

## ◆ reset()

void AMPS::ExponentialDelayStrategy::reset | ( | void |  | ) |
| inline virtual

Reset the state of this reconnect delay.

AMPS calls this method when a connection is successfully established.

Implements AMPS::ReconnectDelayStrategyImpl.

The documentation for this class was generated from the following file:

- include/amps/ReconnectDelayStrategyImpl.hpp