coalescing

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReconciler

func NewReconciler(upstream reconcile.Reconciler, cache ReconcileCacher, log logr.Logger) reconcile.Reconciler

NewReconciler returns a reconcile wrapper that will delay new reconcile.Requests after the cache expiry of the request string key. A successful reconciliation is defined as as one where no error is returned.

Types

type ReconcileCache

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

ReconcileCache uses and underlying time to live last recently used cache to track high frequency requests. A reconciler should call ShouldProcess to determine if the key has expired. If the key has expired, a zero value time.Time and true is returned. If the key has not expired, the expiration and false is returned. Upon successful reconciliation a reconciler should call Reconciled to update the cache expiry.

func NewRequestCache

func NewRequestCache(window time.Duration) (*ReconcileCache, error)

NewRequestCache creates a new instance of a ReconcileCache given a specified window of expiration.

func (*ReconcileCache) Reconciled

func (cache *ReconcileCache) Reconciled(key string)

Reconciled updates the cache expiry for a given key.

func (*ReconcileCache) ShouldProcess

func (cache *ReconcileCache) ShouldProcess(key string) (time.Time, bool)

ShouldProcess determines if the key has expired. If the key has expired, a zero value time.Time and true is returned. If the key has not expired, the expiration and false is returned.

type ReconcileCacher

type ReconcileCacher interface {
	ShouldProcess(key string) (expiration time.Time, ok bool)
	Reconciled(key string)
}

ReconcileCacher describes an interface for determining if a request should be reconciled through a call to ShouldProcess and if ok, reset the cool down through a call to Reconciled.

Directories

Path Synopsis
Package mock_coalescing is a generated GoMock package.
Package mock_coalescing is a generated GoMock package.

Jump to

Keyboard shortcuts

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