Class DefaultRepeat<T>

java.lang.Object
com.couchbase.client.core.retry.reactor.AbstractRetry<T,Long>
com.couchbase.client.core.retry.reactor.DefaultRepeat<T>
All Implemented Interfaces:
Repeat<T>, Function<Flux<Long>,org.reactivestreams.Publisher<Long>>

public class DefaultRepeat<T> extends AbstractRetry<T,Long> implements Repeat<T>
  • Method Details

    • create

      public static <T> DefaultRepeat<T> create(Predicate<? super RepeatContext<T>> repeatPredicate, long n)
      Description copied from interface: Repeat
      Repeat function that repeats n times, only if the predicate returns true.
      Parameters:
      repeatPredicate - Predicate that determines if next repeat is performed
      n - number of repeats
      Returns:
      Repeat function with predicate and n repeats
    • withApplicationContext

      public Repeat<T> withApplicationContext(T applicationContext)
      Description copied from interface: Repeat
      Returns a repeat function with an application context that may be used to perform any rollbacks before a repeat. This application context is provided to any repeat predicate Repeat.onlyIf(Predicate), custom backoff function Repeat.backoff(Backoff) and repeat callback Repeat.doOnRepeat(Consumer). All other properties of this repeat function are retained in the returned instance.
      Specified by:
      withApplicationContext in interface Repeat<T>
      Parameters:
      applicationContext - Application context
      Returns:
      repeat function with associated application context
    • doOnRepeat

      public Repeat<T> doOnRepeat(Consumer<? super RepeatContext<T>> onRepeat)
      Description copied from interface: Repeat
      Returns a repeat function that invokes the provided onRepeat callback before every repeat. The RepeatContext provided to the callback contains the iteration and the any application context set using Repeat.withApplicationContext(Object). All other properties of this repeat function are retained in the returned instance.
      Specified by:
      doOnRepeat in interface Repeat<T>
      Parameters:
      onRepeat - callback to invoke before repeats
      Returns:
      repeat function with callback
    • timeout

      public Repeat<T> timeout(Duration timeout)
      Description copied from interface: Repeat
      Returns a repeat function with timeout. The timeout starts from the instant that this function is applied and switches to unlimited number of attempts. All other properties of this repeat function are retained in the returned instance.
      Specified by:
      timeout in interface Repeat<T>
      Parameters:
      timeout - timeout after which no new repeats are initiated
      Returns:
      repeat function with timeout
    • repeatMax

      public Repeat<T> repeatMax(long maxRepeats)
      Description copied from interface: Repeat
      Returns a repeat function that repeats at most n times. All other properties of this repeat function are retained in the returned instance.
      Specified by:
      repeatMax in interface Repeat<T>
      Parameters:
      maxRepeats - number of repeats
      Returns:
      Retry function for n repeats
    • backoff

      public Repeat<T> backoff(Backoff backoff)
      Description copied from interface: Repeat
      Returns a repeat function with backoff delay. All other properties of this repeat function are retained in the returned instance.
      Specified by:
      backoff in interface Repeat<T>
      Parameters:
      backoff - the backoff function to determine backoff delay
      Returns:
      repeat function with backoff
    • jitter

      public Repeat<T> jitter(Jitter jitter)
      Description copied from interface: Repeat
      Returns a repeat function that applies jitter to the backoff delay. All other properties of this repeat function are retained in the returned instance.
      Specified by:
      jitter in interface Repeat<T>
      Parameters:
      jitter - Jitter function to randomize backoff delay
      Returns:
      repeat function with jitter for backoff
    • withBackoffScheduler

      public Repeat<T> withBackoffScheduler(Scheduler scheduler)
      Description copied from interface: Repeat
      Returns a repeat function that uses the scheduler provided for backoff delays. All other properties of this repeat function are retained in the returned instance.
      Specified by:
      withBackoffScheduler in interface Repeat<T>
      Parameters:
      scheduler - the scheduler for backoff delays
      Returns:
      repeat function with backoff scheduler
    • apply

      public org.reactivestreams.Publisher<Long> apply(Flux<Long> companionValues)
      Specified by:
      apply in interface Function<Flux<Long>,org.reactivestreams.Publisher<Long>>
    • toString

      public String toString()
      Overrides:
      toString in class Object