Atlas › Test

0

Exact test identity: go.temporal.io/server/common/backoff/TestCron/0

Package
go.temporal.io/server/common/backoff
Suite / test hierarchy
TestCron/0
Test
0
Introduced at
cron.go ×1 Frontier kind: Joint frontier
Covered ranges
7
Covered lines
28
Covered files
2

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/backoff/retrypolicy.go 19 covered LOC · 3 ranges

Open complete file

80
81 // NewExponentialRetryPolicy returns an instance of ExponentialRetryPolicy using the provided initialInterval
82 > func NewExponentialRetryPolicy(initialInterval time.Duration) *ExponentialRetryPolicy { retrypolicy.go
83 > p := &ExponentialRetryPolicy{
84 > initialInterval: initialInterval,
85 > backoffCoefficient: defaultBackoffCoefficient,
86 > maximumInterval: defaultMaximumInterval,
87 > expirationInterval: defaultExpirationInterval,
88 > maximumAttempts: defaultMaximumAttempts,
89 > }
90 >
91 > return p
92 > }
93
94 // NewRetrier is used for creating a new instance of Retrier
121 // This does *not* cause the policy to stop retrying when the interval between retries reaches the supplied duration.
122 // That is what WithExpirationInterval does. Instead, this prevents the interval from exceeding maximumInterval.
123 > func (p *ExponentialRetryPolicy) WithMaximumInterval(maximumInterval time.Duration) *ExponentialRetryPolicy { retrypolicy.go
124 > p.maximumInterval = maximumInterval
125 > return p
126 > }
127
128 // WithExpirationInterval sets the absolute expiration interval for all retries
129 > func (p *ExponentialRetryPolicy) WithExpirationInterval(expirationInterval time.Duration) *ExponentialRetryPolicy { retrypolicy.go
130 > p.expirationInterval = expirationInterval
131 > return p
132 > }
133
134 // WithMaximumAttempts sets the maximum number of retry attempts
go.temporal.io/server/common/backoff/cron.go 9 covered LOC · 4 ranges

Open complete file

13
14 // ValidateSchedule validates a cron schedule spec
15 > func ValidateSchedule(cronSchedule string) error { cron.go
16 > if cronSchedule == "" {
17 return nil
18 }
19 > schedule, err := cron.ParseStandard(cronSchedule) cron.go
20 > if err != nil {
21 return serviceerror.NewInvalidArgument("invalid CronSchedule.")
22 }
23 > nextTime := schedule.Next(time.Now().UTC()) cron.go
24 > if nextTime.IsZero() {
25 > // no time can be found to satisfy the schedule cron.go
26 > return serviceerror.NewInvalidArgument("invalid CronSchedule, no time can be found to satisfy the schedule")
27 > }
28 return nil
29 }