Package io.temporal.serviceclient
Class RpcRetryOptions.Builder
- java.lang.Object
-
- io.temporal.serviceclient.RpcRetryOptions.Builder
-
- Enclosing class:
- RpcRetryOptions
public static final class RpcRetryOptions.Builder extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RpcRetryOptions.Builder
addDoNotRetry(io.grpc.Status.Code code, java.lang.Class<? extends com.google.protobuf.GeneratedMessageV3> detailsClass)
Makes request that receives a server response with gRPCcode
and failure ofdetailsClass
type non-retryable.RpcRetryOptions.Builder
addDoNotRetry(RpcRetryOptions.DoNotRetryItem doNotRetryItem)
Makes request that receives a server response with gRPCdoNotRetryItem.code
and failure ofdoNotRetryItem.detailsClass
type non-retryable.RpcRetryOptions
build()
Build RetryOptions without performing validation as validation should be done after merging with MethodRetry.RpcRetryOptions
buildWithDefaultsFrom(RpcRetryOptions rpcRetryOptions)
RpcRetryOptions.Builder
setBackoffCoefficient(double backoffCoefficient)
Coefficient used to calculate the next retry interval.RpcRetryOptions.Builder
setCongestionInitialInterval(java.time.Duration congestionInitialInterval)
Interval of the first retry, on congestion related failures (i.e.RpcRetryOptions.Builder
setExpiration(java.time.Duration expiration)
Maximum time to retry.RpcRetryOptions.Builder
setInitialInterval(java.time.Duration initialInterval)
Interval of the first retry, on regular failures.RpcRetryOptions.Builder
setMaximumAttempts(int maximumAttempts)
When exceeded the amount of attempts, stop.RpcRetryOptions.Builder
setMaximumInterval(java.time.Duration maximumInterval)
Maximum interval between retries.RpcRetryOptions.Builder
setMaximumJitterCoefficient(double maximumJitterCoefficient)
Maximum amount of jitter to apply.RpcRetryOptions.Builder
setRetryOptions(RpcRetryOptions o)
The parameter options takes precedence.RpcRetryOptions
validateBuildWithDefaults()
Validates property values and builds RetryOptions with default values.
-
-
-
Method Detail
-
setInitialInterval
public RpcRetryOptions.Builder setInitialInterval(java.time.Duration initialInterval)
Interval of the first retry, on regular failures. If coefficient is 1.0 then it is used for all retries. Defaults to 50ms.- Parameters:
initialInterval
- Interval to wait on first retry. Default will be used if set tonull
.
-
setCongestionInitialInterval
public RpcRetryOptions.Builder setCongestionInitialInterval(java.time.Duration congestionInitialInterval)
Interval of the first retry, on congestion related failures (i.e. RESOURCE_EXHAUSTED errors). If coefficient is 1.0 then it is used for all retries. Defaults to 1000ms.- Parameters:
congestionInitialInterval
- Interval to wait on first retry, on congestion failures. Defaults to 1000ms, which is used if set tonull
.
-
setExpiration
public RpcRetryOptions.Builder setExpiration(java.time.Duration expiration)
Maximum time to retry. When exceeded the retries stop even if maximum retries is not reached yet. Defaults to 1 minute.At least one of expiration or
setMaximumAttempts(int)
is required to be set.- Parameters:
expiration
- Maximum time to retry. Defaults to 1 minute, which is used if set tonull
.
-
setBackoffCoefficient
public RpcRetryOptions.Builder setBackoffCoefficient(double backoffCoefficient)
Coefficient used to calculate the next retry interval. The next retry interval is previous interval multiplied by this coefficient. Must be 1 or larger. Default is 2.0.- Parameters:
backoffCoefficient
- Coefficient used to calculate the next retry interval. Defaults to 2.0, which is used if set to0
.
-
setMaximumAttempts
public RpcRetryOptions.Builder setMaximumAttempts(int maximumAttempts)
When exceeded the amount of attempts, stop. Even if expiration time is not reached.
Default is unlimited.At least one of maximum attempts or
setExpiration(Duration)
is required to be set.- Parameters:
maximumAttempts
- Maximum number of attempts. Defaults to unlimited, which is used if set to0
.
-
setMaximumInterval
public RpcRetryOptions.Builder setMaximumInterval(java.time.Duration maximumInterval)
Maximum interval between retries. Exponential backoff leads to interval increase. This value is the cap of the increase.
Default is 100x of initial interval. Can't be less thansetInitialInterval(Duration)
- Parameters:
maximumInterval
- the maximum interval value. Defaults to 100x initial interval, which is used if set tonull
.
-
setMaximumJitterCoefficient
public RpcRetryOptions.Builder setMaximumJitterCoefficient(double maximumJitterCoefficient)
Maximum amount of jitter to apply. 0.2 means that actual retry time can be +/- 20% of the calculated time. Set to 0 to disable jitter. Must be lower than 1. Default is 0.1.- Parameters:
maximumJitterCoefficient
- Maximum amount of jitter. Default will be used if set to -1.
-
addDoNotRetry
public RpcRetryOptions.Builder addDoNotRetry(io.grpc.Status.Code code, @Nullable java.lang.Class<? extends com.google.protobuf.GeneratedMessageV3> detailsClass)
Makes request that receives a server response with gRPCcode
and failure ofdetailsClass
type non-retryable.The following gRPC codes are never retried:
Status.Code.CANCELLED
Status.Code.INVALID_ARGUMENT
Status.Code.NOT_FOUND
Status.Code.ALREADY_EXISTS
Status.Code.FAILED_PRECONDITION
Status.Code.PERMISSION_DENIED
Status.Code.UNAUTHENTICATED
Status.Code.UNIMPLEMENTED
- Parameters:
code
- gRPC code to don't retrydetailsClass
- failure type to don't retry.null
means to wildcard, all failures with thecode
code are non retryable.
-
addDoNotRetry
public RpcRetryOptions.Builder addDoNotRetry(RpcRetryOptions.DoNotRetryItem doNotRetryItem)
Makes request that receives a server response with gRPCdoNotRetryItem.code
and failure ofdoNotRetryItem.detailsClass
type non-retryable.The following gRPC codes are never retried:
Status.Code.CANCELLED
Status.Code.INVALID_ARGUMENT
Status.Code.NOT_FOUND
Status.Code.ALREADY_EXISTS
Status.Code.FAILED_PRECONDITION
Status.Code.PERMISSION_DENIED
Status.Code.UNAUTHENTICATED
Status.Code.UNIMPLEMENTED
- Parameters:
doNotRetryItem
- specifies gRPC code and failure type that shouldn't be retried. IfdoNotRetryItem.detailsClass==null
, all failures with thedoNotRetryItem.code
code are non retryable.
-
setRetryOptions
public RpcRetryOptions.Builder setRetryOptions(RpcRetryOptions o)
The parameter options takes precedence.
-
build
public RpcRetryOptions build()
Build RetryOptions without performing validation as validation should be done after merging with MethodRetry.
-
buildWithDefaultsFrom
public RpcRetryOptions buildWithDefaultsFrom(RpcRetryOptions rpcRetryOptions)
-
validateBuildWithDefaults
public RpcRetryOptions validateBuildWithDefaults()
Validates property values and builds RetryOptions with default values.
-
-