Support NewCustomError that doesn't always retry
peaaceChoi opened this issue · comments
Is your feature request related to a problem? Please describe.
NonRetriableErrorReasons
are supposed to cadence errors in all cases where retry is not required. However, Activity has many conditions that do not need to be retried.
If validation for input fails as in the example below, there is no need to retry. This is because the same error is repeated.
RetryPolicy: &cadence.RetryPolicy{
InitialInterval: time.Second,
BackoffCoefficient: 2.0,
MaximumInterval: time.Minute,
ExpirationInterval: time.Minute * 10,
NonRetriableErrorReasons: []string{"ErrInvalidInput01",
"ErrInvalidInput02",
"ErrInvalidInput03",...},
},
The problem is, if there is a large number of errors such as input validation, the NonRetriableErrorReasons
must be described in all retry policy.
Proposed Solution
It can be solved in various ways, but I think it will be the simplest to add the noRetry related function
to the newCustomError
of the cadence client.
the user is not required to use Non Retriable Error Reasons
if can identify specific errors by using the prefix of the new custom errors as shown below.
func NewCustomErrorWithNoRetry(reason string, details ...interface{}) *CustomError {
return internal.NewCustomError("cadenceInternal:NoRetry:"+reason, details...)
}
Justly, need to modify the decision codes below.
cadence client
cadence-client/internal/internal_task_handlers.go
Lines 1046 to 1050 in 5282e89