203
// NewConditionalRetryPolicy returns a policy that delegates to whenTrue when
204
// predicate(err) is true, and whenFalse otherwise.
205
>
func NewConditionalRetryPolicy(predicate func(err error) bool, whenTrue, whenFalse RetryPolicy) *ConditionalRetryPolicy {
retrypolicy.go
206
>
return &ConditionalRetryPolicy{
207
>
predicate: predicate,
208
>
whenTrue: whenTrue,
209
>
whenFalse: whenFalse,
210
>
}
211
>
}
212
213
>
func (p *ConditionalRetryPolicy) ComputeNextDelay(elapsedTime time.Duration, numAttempts int, err error) time.Duration {
retrypolicy.go
214
>
if p.predicate(err) {
215
return p.whenTrue.ComputeNextDelay(elapsedTime, numAttempts, err)
216
}