Interface RetrySchema

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface RetrySchema
Defines delay for next read/poll operation in a polling publisher.

Schema defines a delay before next poll if the last one did not get new data.

It is possible to use included static factory methods for some standard schemas.

  • Method Summary

    Modifier and Type
    Method
    Description
    constant(long delay)
    Creates the retry schema with a constant result.
    geometric(long firstDelay, double ratio, long maxDelay)
    Creates the retry schema as a bounded geometric series.
    linear(long firstDelay, long delayIncrement, long maxDelay)
    Creates the retry schema with a linear delay increment.
    long
    nextDelay(int retryCount, long lastDelay)
    Returns a delay before next read if the last one poll did not get new data.
  • Method Details

    • nextDelay

      long nextDelay(int retryCount, long lastDelay)
      Returns a delay before next read if the last one poll did not get new data.
      Parameters:
      retryCount - a count of already poll retries. It is 0 when called first time and resets every time when poll returns some data.
      lastDelay - a last returned value. 0 in first call. Resets when some data are get.
      Returns:
      a delay in milliseconds before next poll attempt. If less then zero then Publisher completes with onError message.
    • linear

      static RetrySchema linear(long firstDelay, long delayIncrement, long maxDelay)
      Creates the retry schema with a linear delay increment. It returns firstDelay for the first call and then it increments it's value for every call by delayIncrement until reach a limit defined by maxDelay.
      Parameters:
      firstDelay - a delay to returns for the first call
      delayIncrement - an increment of the returned value.
      maxDelay - the maximal value to return
      Returns:
      computed retry delay with a linear increment
    • constant

      static RetrySchema constant(long delay)
      Creates the retry schema with a constant result.
      Parameters:
      delay - a constant delay to return
      Returns:
      a delay value
    • geometric

      static RetrySchema geometric(long firstDelay, double ratio, long maxDelay)
      Creates the retry schema as a bounded geometric series.
      Parameters:
      firstDelay - a delay to returns for the first call
      ratio - a geometric series ratio
      maxDelay - the maximal value to return
      Returns:
      computed retry delay