backoff

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposeResourceKey

func ComposeResourceKey(o k8s.Resource) string

func GetComputeResourceAndQuantityRequested

func GetComputeResourceAndQuantityRequested(err error) v1.ResourceList

func IsBackOffError added in v0.2.26

func IsBackOffError(err error) bool

func IsBackoffError

func IsBackoffError(err error) bool

func IsResourceQuotaExceeded

func IsResourceQuotaExceeded(err error) bool

Types

type AtomicTime added in v0.2.21

type AtomicTime struct {
	// contains filtered or unexported fields
}

AtomicTime represents an atomic.Value that stores time.Time.

func NewAtomicTime added in v0.2.21

func NewAtomicTime(t time.Time) AtomicTime

Creates a new Atomic time.Time

func (*AtomicTime) Load added in v0.2.21

func (a *AtomicTime) Load() time.Time

Loads the underlying time.Time.

func (*AtomicTime) Store added in v0.2.21

func (a *AtomicTime) Store(t time.Time)

Stores time.Time to the underlying atomic.Value

type ComputeResourceAwareBackOffHandler

type ComputeResourceAwareBackOffHandler struct {
	*SimpleBackOffBlocker
	*ComputeResourceCeilings
}

ComputeResourceAwareBackOffHandler is an exponential back-off handler that also keeps track of the resource ceilings of the operations that are blocked or failed due to resource insufficiency

func (*ComputeResourceAwareBackOffHandler) Handle

func (h *ComputeResourceAwareBackOffHandler) Handle(ctx context.Context, operation func() error, requestedResourceList v1.ResourceList) error

Act based on current backoff interval and set the next one accordingly

func (*ComputeResourceAwareBackOffHandler) IsActive

type ComputeResourceCeilings

type ComputeResourceCeilings struct {
	// contains filtered or unexported fields
}

type Controller

type Controller struct {
	// Controller.Clock allows the use of fake clock when testing
	Clock clock.Clock
	// contains filtered or unexported fields
}

Controller is a name-spaced collection of back-off handlers

func NewController

func NewController(ctx context.Context) *Controller

func (*Controller) GetBackOffHandler

func (m *Controller) GetBackOffHandler(key string) (*ComputeResourceAwareBackOffHandler, bool)

func (*Controller) GetOrCreateHandler

func (m *Controller) GetOrCreateHandler(ctx context.Context, key string, backOffBaseSecond int, maxBackOffDuration time.Duration) *ComputeResourceAwareBackOffHandler

type HandlerMap

type HandlerMap struct {
	sync.Map
}

func (*HandlerMap) Get

func (*HandlerMap) Set

type SimpleBackOffBlocker

type SimpleBackOffBlocker struct {
	Clock              clock.Clock
	BackOffBaseSecond  int
	MaxBackOffDuration time.Duration

	// Mutable fields
	BackOffExponent  stdAtomic.Uint32
	NextEligibleTime AtomicTime
}

SimpleBackOffBlocker is a simple exponential back-off timer that keeps track of the back-off period

Jump to

Keyboard shortcuts

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