Stack backoff rework (#83)

* huge Stack backoff rework

* lneto bump: huge Stack backoff rework
This commit is contained in:
Pat Whittingslow
2026-04-14 21:05:02 -03:00
committed by GitHub
parent 75a812a8d7
commit 16c2c3de36
13 changed files with 153 additions and 85 deletions
+4 -3
View File
@@ -17,13 +17,14 @@ const (
// Useful for when the BackoffStrategy implements its own yield.
// - Returns [BackoffFlagGosched]: Signal [runtime.Gosched] should be called.
//
// consecutiveBackoffs starts at 1 and increments by 1 every time the operation is retried.
// Despite the name(changes welcome) consecutiveBackoffs starts at 0 and
// increments by 1 every time the operation is retried.
// See internal/backoff.go for a implementation example.
type BackoffStrategy func(consecutiveBackoffs int) (sleepOrFlag time.Duration)
type BackoffStrategy func(consecutiveBackoffs uint) (sleepOrFlag time.Duration)
// Do applies the backoff strategy by calling backoff(consecutiveBackoffs)
// and then the corresponding yield function for the returned value. See [BackoffStrategy].
func (backoff BackoffStrategy) Do(consecutiveBackoffs int) {
func (backoff BackoffStrategy) Do(consecutiveBackoffs uint) {
sleep := backoff(consecutiveBackoffs)
switch sleep {
case BackoffFlagNop: