Documentation ¶
Index ¶
- func ComposeResourceKey(o client.Object) string
- func GetComputeResourceAndQuantity(err error, resourceRegex *regexp.Regexp) v1.ResourceList
- func IsBackOffError(err error) bool
- func IsResourceQuotaExceeded(err error) bool
- func IsResourceRequestsEligible(err error) bool
- type AtomicTime
- type ComputeResourceAwareBackOffHandler
- type ComputeResourceCeilings
- type Controller
- type HandlerMap
- type SimpleBackOffBlocker
- type SyncResourceList
- func (s *SyncResourceList) AddResourceList(list v1.ResourceList) *SyncResourceList
- func (s *SyncResourceList) AsResourceList() v1.ResourceList
- func (s *SyncResourceList) Load(resourceName v1.ResourceName) (quantity resource.Quantity, found bool)
- func (s *SyncResourceList) Range(visitor func(key v1.ResourceName, value resource.Quantity) bool)
- func (s *SyncResourceList) Store(resourceName v1.ResourceName, quantity resource.Quantity)
- func (s *SyncResourceList) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComposeResourceKey ¶
func GetComputeResourceAndQuantity ¶
func GetComputeResourceAndQuantity(err error, resourceRegex *regexp.Regexp) v1.ResourceList
func IsBackOffError ¶
func IsResourceQuotaExceeded ¶
Types ¶
type AtomicTime ¶
type AtomicTime struct {
// contains filtered or unexported fields
}
AtomicTime represents an atomic.Value that stores time.Time.
func (*AtomicTime) Store ¶
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 ¶
func (h *ComputeResourceAwareBackOffHandler) IsActive() bool
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 ¶
func (*HandlerMap) Get ¶
func (m *HandlerMap) Get(key string) (*ComputeResourceAwareBackOffHandler, bool)
func (*HandlerMap) Set ¶
func (m *HandlerMap) Set(key string, value *ComputeResourceAwareBackOffHandler)
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
type SyncResourceList ¶
SyncResourceList is a thread-safe Map. It's meant to replace v1.ResourceList for concurrency-sensitive code.
func NewSyncResourceList ¶
func NewSyncResourceList() *SyncResourceList
NewSyncResourceList creates a thread-safe map to store resource names and resource quantities. Equivalent to v1.ResourceList but offering concurrent-safe operations.
func (*SyncResourceList) AddResourceList ¶
func (s *SyncResourceList) AddResourceList(list v1.ResourceList) *SyncResourceList
AddResourceList stores a list into the sync map.
func (*SyncResourceList) AsResourceList ¶
func (s *SyncResourceList) AsResourceList() v1.ResourceList
AsResourceList serializes a snapshot of the sync map into a v1.ResourceList
func (*SyncResourceList) Load ¶
func (s *SyncResourceList) Load(resourceName v1.ResourceName) (quantity resource.Quantity, found bool)
Load loads a resource quantity if one exists.
func (*SyncResourceList) Range ¶
func (s *SyncResourceList) Range(visitor func(key v1.ResourceName, value resource.Quantity) bool)
Range iterates over all the entries of the list in a non-sorted non-deterministic order.
func (*SyncResourceList) Store ¶
func (s *SyncResourceList) Store(resourceName v1.ResourceName, quantity resource.Quantity)
Store stores the value in the map overriding existing value or adding a new one of one doesn't exist.
func (*SyncResourceList) String ¶
func (s *SyncResourceList) String() string
String returns a formatted string of some snapshot of the map ordered by keys.