Skip to content

Commit 51ed9ce

Browse files
committed
describe retry policy a bit more carefully
1 parent 0e571da commit 51ed9ce

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

internal/client.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,35 @@ type (
493493
// This value is the cap of the interval. Default is 100x of initial interval.
494494
MaximumInterval time.Duration
495495

496-
// Maximum time to retry. Either ExpirationInterval or MaximumAttempts is required.
496+
// Maximum time to attempt to retry. Either ExpirationInterval or MaximumAttempts is required.
497+
//
497498
// When exceeded the retries stop even if maximum retries is not reached yet.
499+
//
500+
// Note that this applies to the retry policy itself, not the thing being retried - an
501+
// ExpirationInterval of 1s will not cancel an activity that runs longer than one second.
502+
//
503+
// E.g. a 1-hour-long StartToClose activity with a 5 minute RetryPolicy.ExpirationInterval
504+
// will lead to both this kind of behavior:
505+
// - be called once
506+
// - fail within 30 seconds
507+
// - be retried (30 < ExpirationInterval)
508+
// - fail again after 5 minutes
509+
// - not be retried (5m30s > ExpirationInterval)
510+
// and this:
511+
// - be called once
512+
// - fail after 10m
513+
// - not be retried (10m > ExpirationInterval)
498514
ExpirationInterval time.Duration
499515

500-
// Maximum number of attempts. When exceeded the retries stop even if not expired yet.
516+
// Maximum number of attempts to perform, including the initial call.
517+
// When exceeded, no further retries will occur even if the expiration interval has not passed.
518+
//
501519
// If not set or set to 0, it means unlimited, and rely on ExpirationInterval to stop.
502520
// Either MaximumAttempts or ExpirationInterval is required.
521+
//
522+
// CAUTION: MaximumAttempts of 1 does not allow any "retries", as the first attempt will occur
523+
// even without a retry policy. E.g. if you want an activity to be able to fail and be retried once,
524+
// set MaximumAttempts to 2.
503525
MaximumAttempts int32
504526

505527
// Non-Retriable errors. This is optional. Cadence server will stop retry if error reason matches this list.

0 commit comments

Comments
 (0)