Documentation ¶
Index ¶
- func BackoffWithContext(ctx context.Context, backoff wait.Backoff, condition wait.ConditionFunc) error
- func GetKeyForSyncMetrics(namespace string, name string) string
- func WaitAll(w ...Waiter) error
- type MetricsCache
- func (c *MetricsCache) AddKind(key string)
- func (c *MetricsCache) AddObject(key string, t Tags)
- func (c *MetricsCache) DeleteObject(key string)
- func (c *MetricsCache) GetTags(key string) *Tags
- func (c *MetricsCache) HasObject(key string) bool
- func (c *MetricsCache) ReportSync()
- func (c *MetricsCache) ResetCache()
- type Reporter
- type SingleRunner
- type SyncBool
- type Tags
- type Waiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackoffWithContext ¶
func BackoffWithContext(ctx context.Context, backoff wait.Backoff, condition wait.ConditionFunc) error
BackoffWithContext repeats a condition check with exponential backoff, exiting early if the provided context is canceled.
It repeatedly checks the condition and then sleeps, using `backoff.Step()` to determine the length of the sleep and adjust Duration and Steps. Stops and returns as soon as: 1. the condition check returns true or an error, or 2. the context is canceled. In case (1) the returned error is what the condition function returned. In all other cases, wait.ErrorInterrupted is returned.
Adapted from wait.ExponentialBackoff in https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/wait/wait.go
func GetKeyForSyncMetrics ¶
Types ¶
type MetricsCache ¶
type MetricsCache struct { Cache map[string]Tags KnownKinds map[string]bool // contains filtered or unexported fields }
func NewMetricsCache ¶
func NewMetricsCache() *MetricsCache
func (*MetricsCache) AddKind ¶
func (c *MetricsCache) AddKind(key string)
need to know encountered kinds to reset metrics for that kind this is a known memory leak footprint should naturally reset on Pod upgrade b/c the container restarts.
func (*MetricsCache) AddObject ¶
func (c *MetricsCache) AddObject(key string, t Tags)
func (*MetricsCache) DeleteObject ¶
func (c *MetricsCache) DeleteObject(key string)
func (*MetricsCache) GetTags ¶ added in v3.14.0
func (c *MetricsCache) GetTags(key string) *Tags
func (*MetricsCache) HasObject ¶ added in v3.14.0
func (c *MetricsCache) HasObject(key string) bool
func (*MetricsCache) ReportSync ¶
func (c *MetricsCache) ReportSync()
func (*MetricsCache) ResetCache ¶
func (c *MetricsCache) ResetCache()
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
func NewStatsReporter ¶
NewStatsReporter creates a reporter for sync metrics.
func (*Reporter) ReportLastSync ¶
type SingleRunner ¶
type SingleRunner struct {
// contains filtered or unexported fields
}
SingleRunner wraps an errgroup to run keyed goroutines as singletons. Keys are single-use and subsequent usage to schedule will be silently ignored. Goroutines can be individually canceled provided they respect the context passed to them.
func RunnerWithContext ¶
func RunnerWithContext(ctx context.Context) *SingleRunner
RunnerWithContext returns an initialized SingleRunner. The provided context is used as the parent of subsequently scheduled goroutines.
func (*SingleRunner) Cancel ¶
func (s *SingleRunner) Cancel(key string)
Cancel cancels a keyed goroutine if it exists.
func (*SingleRunner) Go ¶
Go schedules the provided function on a new goroutine if the provided key has not been used for scheduling before.
func (*SingleRunner) Wait ¶
func (s *SingleRunner) Wait() error
Wait waits for all goroutines managed by the SingleRunner to complete. Returns the first error returned from a managed goroutine, or nil.