Package markets.alpaca.client.ws
Class AlpacaStreamReconnectPolicy
java.lang.Object
markets.alpaca.client.ws.AlpacaStreamReconnectPolicy
Reconnect policy for Alpaca WebSocket stream clients.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUse this value forAlpacaStreamReconnectPolicy.Builder.maxAttempts(int)to retry forever. -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowsAttempt(int attempt) builder()static AlpacaStreamReconnectPolicyReturns the default policy: 10 attempts, starting at 1 second, capped at 64 seconds, with 20% jitter.longdelayMillisForAttempt(int attempt) static AlpacaStreamReconnectPolicydisabled()Returns a policy that never reconnects after an unexpected close or transport failure.longjitteredDelayMillisForAttempt(int attempt) Returns the reconnect delay forattempt, with configured jitter applied.doubleRatio used to randomize reconnect delays.intMaximum reconnect attempts after one successful connection.
-
Field Details
-
UNLIMITED_ATTEMPTS
public static final int UNLIMITED_ATTEMPTSUse this value forAlpacaStreamReconnectPolicy.Builder.maxAttempts(int)to retry forever.- See Also:
-
-
Method Details
-
defaultPolicy
Returns the default policy: 10 attempts, starting at 1 second, capped at 64 seconds, with 20% jitter. -
disabled
Returns a policy that never reconnects after an unexpected close or transport failure. -
builder
-
initialBackoff
-
maxBackoff
-
maxAttempts
public int maxAttempts()Maximum reconnect attempts after one successful connection.0disables reconnects.UNLIMITED_ATTEMPTSretries forever. -
jitterRatio
public double jitterRatio()Ratio used to randomize reconnect delays.0disables jitter. -
allowsAttempt
public boolean allowsAttempt(int attempt) -
delayMillisForAttempt
public long delayMillisForAttempt(int attempt) -
jitteredDelayMillisForAttempt
public long jitteredDelayMillisForAttempt(int attempt) Returns the reconnect delay forattempt, with configured jitter applied.
-