MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / MakeBackoffIntervalFunc

Function MakeBackoffIntervalFunc

pkg/task/task.go:73–86  ·  view source on GitHub ↗

MakeBackoffIntervalFunc returns a new BackoffIntervalFunc.

(onFailure bool, resetDuration time.Duration, intervals ...time.Duration)

Source from the content-addressed store, hash-verified

71
72// MakeBackoffIntervalFunc returns a new BackoffIntervalFunc.
73func MakeBackoffIntervalFunc(onFailure bool, resetDuration time.Duration, intervals ...time.Duration) BackoffIntervalFunc {
74 return func(ctx context.Context, executionDuration time.Duration, invocation uint, err error) time.Duration {
75 switch {
76 case onFailure && err == nil:
77 return 0
78 case executionDuration > resetDuration:
79 return intervals[0]
80 case invocation >= uint(len(intervals)):
81 return intervals[len(intervals)-1]
82 default:
83 return intervals[invocation-1]
84 }
85 }
86}
87
88// Values for DefaultBackoffConfig.
89const (

Callers 4

networkserver.goFile · 0.92
initFunction · 0.92
task.goFile · 0.85

Calls

no outgoing calls

Tested by 1

initFunction · 0.74