retry

package
v0.16.13-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2020 License: Apache-2.0 Imports: 3 Imported by: 3,414

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBackoff = wait.Backoff{
	Steps:    4,
	Duration: 10 * time.Millisecond,
	Factor:   5.0,
	Jitter:   0.1,
}

DefaultBackoff is the recommended backoff for a conflict where a client may be attempting to make an unrelated modification to a resource under active management by one or more controllers.

View Source
var DefaultRetry = wait.Backoff{
	Steps:    5,
	Duration: 10 * time.Millisecond,
	Factor:   1.0,
	Jitter:   0.1,
}

DefaultRetry is the recommended retry for a conflict where multiple clients are making changes to the same resource.

Functions

func OnError added in v0.16.4

func OnError(backoff wait.Backoff, errorFunc func(error) bool, fn func() error) error

OnError executes the provided function repeatedly, retrying if the server returns a specified error. Callers should preserve previous executions if they wish to retry changes. It performs an exponential backoff.

var pod *api.Pod
err := retry.OnError(DefaultBackoff, errors.IsConflict, func() (err error) {
  pod, err = c.Pods("mynamespace").UpdateStatus(podStatus)
  return
})
if err != nil {
  // may be conflict if max retries were hit
  return err
}
...

TODO: Make Backoff an interface?

func RetryOnConflict

func RetryOnConflict(backoff wait.Backoff, fn func() error) error

RetryOnConflict executes the function function repeatedly, retrying if the server returns a conflicting

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL