57
58
// Validate validates a retry policy
60
>
if policy == nil {
61
// nil policy is valid which means no retry
62
return nil
63
}
64
66
// One maximum attempt effectively disable retries. Validating the
67
// rest of the arguments is pointless
68
return nil
69
}
70
>
if err := timestamp.ValidateAndCapProtoDuration(policy.GetInitialInterval()); err != nil {
retry_policy.go
71
return serviceerror.NewInvalidArgumentf("invalid InitialInterval set on retry policy: %v", err)
72
}
74
return serviceerror.NewInvalidArgument("BackoffCoefficient cannot be less than 1 on retry policy.")
75
}
76
>
if err := timestamp.ValidateAndCapProtoDuration(policy.GetMaximumInterval()); err != nil {
retry_policy.go
77
return serviceerror.NewInvalidArgumentf("invalid MaximumInterval set on retry policy: %v", err)
78
}
79
>
if timestamp.DurationValue(policy.GetMaximumInterval()) > 0 && timestamp.DurationValue(policy.GetMaximumInterval()) < timestamp.DurationValue(policy.GetInitialInterval()) {
retry_policy.go
80
return serviceerror.NewInvalidArgument("MaximumInterval cannot be less than InitialInterval on retry policy.")
81
}
83
>
return serviceerror.NewInvalidArgument("MaximumAttempts cannot be negative on retry policy.")
retry_policy.go
84
>
}
85
86
for _, nrt := range policy.NonRetryableErrorTypes {