Class AlpacaSseReconnectPolicy

java.lang.Object
markets.alpaca.client.sse.AlpacaSseReconnectPolicy

public final class AlpacaSseReconnectPolicy extends Object
Retry and backoff settings for Server-Sent Events connections.
  • Field Details

    • UNLIMITED_ATTEMPTS

      public static final int UNLIMITED_ATTEMPTS
      Retry forever after an established stream disconnects.
      See Also:
  • Method Details

    • defaultPolicy

      public static AlpacaSseReconnectPolicy defaultPolicy()
      Returns the resilient Trading default: two initial retries and unlimited live reconnects.
    • disabled

      public static AlpacaSseReconnectPolicy disabled()
      Returns a policy that never reconnects.
    • builder

      public static AlpacaSseReconnectPolicy.Builder builder()
    • toBuilder

    • initialAttempts

      public int initialAttempts()
    • establishedAttempts

      public int establishedAttempts()
    • initialBackoff

      public Duration initialBackoff()
      Returns the first client backoff and the minimum accepted server-directed reconnect delay.

      SSE retry: and HTTP Retry-After values below this duration are raised to this value to prevent tight reconnect loops.

    • maxBackoff

      public Duration maxBackoff()
      Returns the maximum reconnect delay.

      The cap applies to client exponential backoff, server-provided SSE retry: values, and HTTP Retry-After values.

    • maxElapsedTime

      public Duration maxElapsedTime()
      Returns the maximum elapsed time for one reconnect cycle, or null when unbounded.

      The initial cycle spans connection attempts and backoff until the first accepted response. An established cycle starts after a transient disconnect and resets after an event is delivered. It remains active after reconnect headers during comments or silence. The budget includes connection time, lifecycle callback execution, client backoff, retry:, and Retry-After delays.

      This is separate from AlpacaSseOptions.maxDuration(), which limits the lifetime of the entire subscription.

    • jitterRatio

      public double jitterRatio()
    • allowsAttempt

      public boolean allowsAttempt(boolean established, int attempt)
    • delayForAttempt

      public Duration delayForAttempt(int attempt)