mirror of
https://github.com/soypat/lneto.git
synced 2026-08-17 13:23:30 +00:00
Stack backoff rework (#83)
* huge Stack backoff rework * lneto bump: huge Stack backoff rework
This commit is contained in:
+4
-3
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user