MCPcopy Create free account
hub / github.com/cloudbase/garm / ShouldProcess

Method ShouldProcess

locking/local_backoff_locker.go:39–56  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

37}
38
39func (i *instanceDeleteBackoff) ShouldProcess(key string) (bool, time.Time) {
40 backoff, loaded := i.muxes.LoadOrStore(key, &instanceBackOff{})
41 if !loaded {
42 return true, time.Time{}
43 }
44
45 ib := backoff.(*instanceBackOff)
46 ib.mux.Lock()
47 defer ib.mux.Unlock()
48
49 if ib.lastRecordedFailureTime.IsZero() || ib.backoffSeconds == 0 {
50 return true, time.Time{}
51 }
52
53 now := time.Now().UTC()
54 deadline := ib.lastRecordedFailureTime.Add(time.Duration(ib.backoffSeconds) * time.Second)
55 return now.After(deadline), deadline
56}
57
58func (i *instanceDeleteBackoff) Delete(key string) {
59 i.muxes.Delete(key)

Callers

nothing calls this directly

Calls 4

AddMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
DurationMethod · 0.45

Tested by

no test coverage detected