Class DefaultContext<T>
- java.lang.Object
-
- com.couchbase.client.core.retry.reactor.DefaultContext<T>
-
- All Implemented Interfaces:
IterationContext<T>,RepeatContext<T>,RetryContext<T>
public class DefaultContext<T> extends Object implements RetryContext<T>, RepeatContext<T>
-
-
Constructor Summary
Constructors Constructor Description DefaultContext(T applicationContext, long iteration, BackoffDelay backoff, long repeatCompanionValue)DefaultContext(T applicationContext, long iteration, BackoffDelay backoff, Throwable exception)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TapplicationContext()Application context that may be used to perform any rollbacks before a retry.Durationbackoff()The backoff delay.LongcompanionValue()Returns the value provided in the companion Flux for repeats.Throwableexception()Returns the exception from the last iteration.longiteration()The next iteration number.StringtoString()
-
-
-
Constructor Detail
-
DefaultContext
public DefaultContext(T applicationContext, long iteration, BackoffDelay backoff, long repeatCompanionValue)
-
DefaultContext
public DefaultContext(T applicationContext, long iteration, BackoffDelay backoff, Throwable exception)
-
-
Method Detail
-
applicationContext
public T applicationContext()
Description copied from interface:IterationContextApplication context that may be used to perform any rollbacks before a retry. Application context can be configured usingRetry.withApplicationContext(Object)orRepeat.withApplicationContext(Object).- Specified by:
applicationContextin interfaceIterationContext<T>- Returns:
- application context
-
iteration
public long iteration()
Description copied from interface:IterationContextThe next iteration number. This is a zero-based incrementing number with the first attempt prior to any retries as iteration zero.- Specified by:
iterationin interfaceIterationContext<T>- Returns:
- the current iteration number
-
companionValue
public Long companionValue()
Description copied from interface:RepeatContextReturns the value provided in the companion Flux for repeats.- For
Flux.repeatWhen(java.util.function.Function)andMono.repeatWhen(java.util.function.Function), value is the number of items emitted in the last attempt. - For
Mono.repeatWhenEmpty(java.util.function.Function)andMono.repeatWhenEmpty(int, java.util.function.Function), value is a zero-based incrementing Long, which is number of attempts - 1.
- Specified by:
companionValuein interfaceRepeatContext<T>- Returns:
- value the value emitted on the companion Flux for repeats.
- For
-
exception
public Throwable exception()
Description copied from interface:RetryContextReturns the exception from the last iteration.- Specified by:
exceptionin interfaceRetryContext<T>- Returns:
- exception that resulted in retry
-
backoff
public Duration backoff()
Description copied from interface:IterationContextThe backoff delay. WhenBackofffunction is invoked, the previous backoff is provided in the context. The context provided for the retry predicatesRetry.onlyIf(java.util.function.Predicate)andRepeat.onlyIf(java.util.function.Predicate)as well as the retry callbacksRetry.doOnRetry(java.util.function.Consumer)andRepeat.doOnRepeat(java.util.function.Consumer)provide the backoff delay for the next retry.- Specified by:
backoffin interfaceIterationContext<T>- Returns:
- Backoff delay
-
-