ExponentialDelayStrategy is an implementation that exponentially "backs off" when reconnecting to the same server, including optional jitter when backing off and a maximum amount of time to attempt reconnection before giving up entirely.
More...
|
const int | DEFAULT_DELAY = 200 |
| The default time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection. More...
|
|
const int | DEFAULT_MAXIMUM_DELAY = 20 * 1000 |
| The default maximum time to wait between any reconnection attempts. Exponential backoff will not exceed this maximum. More...
|
|
const double | DEFAULT_BACKOFF_EXPONENT = 2.0 |
| The default 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. More...
|
|
const double | DEFAULT_MAXIMUM_RETRY_TIME = -1.0 |
| The default time (in millseconds) to allow reconnect attempts to continue without a successful connection, before "giving up" and abandoning the connection attempt. 0 means never give up. More...
|
|
const double | DEFAULT_JITTER = 1.0 |
| 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. More...
|
|
|
int | _initialDelay |
|
int | _maximumDelay |
|
double | _backoffExponent |
|
double | _maximumRetryTime |
|
double | _jitter |
|
int | _currentDelay |
|
String | _lastUri |
|
String | _firstUri |
|
DateTime | _endTime |
|
Random | _random = new Random() |
|
ExponentialDelayStrategy is an implementation that exponentially "backs off" when reconnecting to the same server, including optional jitter when backing off and a maximum amount of time to attempt reconnection before giving up entirely.
◆ ExponentialDelayStrategy()
AMPS.Client.ExponentialDelayStrategy.ExponentialDelayStrategy |
( |
| ) |
|
|
inline |
◆ _currentDurationAndIncrease()
int AMPS.Client.ExponentialDelayStrategy._currentDurationAndIncrease |
( |
| ) |
|
|
inlineprotected |
Returns the _currentDelay, and also expands _currentDelay based on the configured exponent and maximum.
- Returns
- The delay that should be used, prior to increasing it.
◆ _throwIfMaximumExceeded()
void AMPS.Client.ExponentialDelayStrategy._throwIfMaximumExceeded |
( |
| ) |
|
|
inlineprotected |
An internal function used to check if the configured retry has been exceeded, and if so, throw MaximumRetryExceeded to cause the calling HAClient to give up on reconnecting to a server.
◆ getConnectWaitDuration()
int AMPS.Client.ExponentialDelayStrategy.getConnectWaitDuration |
( |
String |
uri_ | ) |
|
|
inline |
Returns the time (in milliseconds) that the client should wait before connecting to the given server URI.
- Parameters
-
uri_ | The URI to which the client plans to connect. |
- Exceptions
-
Exception | Any exception thrown indicates no connection should be attempted. The client, in essence, should "give up." |
Implements AMPS.Client.ReconnectDelayStrategy.
◆ reset()
void AMPS.Client.ExponentialDelayStrategy.reset |
( |
| ) |
|
|
inline |
◆ setBackoffExponent()
Sets 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.
- Returns
- self
- Parameters
-
exponent_ | The new exponent value. |
◆ setInitialDelay()
Sets the time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection.
- Returns
- self
- Parameters
-
initialDelay_ | The new initial delay value, in milliseconds. |
◆ setJitter()
Sets the jitter factor used to add randomness to the delay time. Jitter is represented as a multiple of the initial delay time; a random number from [0, (JITTER * INITIAL_DELAY) ) is added to nonzero time delays.
- Returns
- self
- Parameters
-
jitter_ | The jitter factor, in multiples of the initial delay. |
◆ setMaximumDelay()
Sets the maximum time to wait between any reconnection attempts. Exponential backoff will not exceed this maximum.
- Returns
- self
- Parameters
-
maximumDelay_ | The new maximum delay value, in milliseconds. |
◆ setMaximumRetryTime()
Sets the time (in millseconds) to allow reconnect attempts to continue without a successful connection, before "giving up" and abandoning the connection attempt. 0 means never give up.
- Returns
- self
- Parameters
-
maximumRetryTime_ | The new maximum retry time, in milliseconds. |
◆ DEFAULT_BACKOFF_EXPONENT
const double AMPS.Client.ExponentialDelayStrategy.DEFAULT_BACKOFF_EXPONENT = 2.0 |
|
static |
The default 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.
◆ DEFAULT_DELAY
const int AMPS.Client.ExponentialDelayStrategy.DEFAULT_DELAY = 200 |
|
static |
The default time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection.
◆ DEFAULT_JITTER
const double AMPS.Client.ExponentialDelayStrategy.DEFAULT_JITTER = 1.0 |
|
static |
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.
◆ DEFAULT_MAXIMUM_DELAY
const int AMPS.Client.ExponentialDelayStrategy.DEFAULT_MAXIMUM_DELAY = 20 * 1000 |
|
static |
The default maximum time to wait between any reconnection attempts. Exponential backoff will not exceed this maximum.
◆ DEFAULT_MAXIMUM_RETRY_TIME
const double AMPS.Client.ExponentialDelayStrategy.DEFAULT_MAXIMUM_RETRY_TIME = -1.0 |
|
static |
The default time (in millseconds) to allow reconnect attempts to continue without a successful connection, before "giving up" and abandoning the connection attempt. 0 means never give up.
The documentation for this class was generated from the following file:
- AMPS.Client/ExponentialDelayStrategy.cs