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 FilteredDataClient
- type MetricsCache
- type OpaDataClient
- 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 FilteredDataClient ¶
type FilteredDataClient struct {
// contains filtered or unexported fields
}
FilteredDataClient is an OpaDataClient which drops any unwatched resources.
func NewFilteredOpaDataClient ¶
func NewFilteredOpaDataClient(opa OpaDataClient, watchSet *watch.Set) *FilteredDataClient
func (*FilteredDataClient) AddData ¶
func (f *FilteredDataClient) AddData(ctx context.Context, data interface{}) (*types.Responses, error)
AddData adds data to the opa cache if that data is currently being watched. Unwatched data is silently dropped with no error.
func (*FilteredDataClient) RemoveData ¶
func (f *FilteredDataClient) RemoveData(ctx context.Context, data interface{}) (*types.Responses, error)
RemoveData removes data from the opa cache if that data is currently being watched. Unwatched data is silently dropped with no error.
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) ReportSync ¶
func (c *MetricsCache) ReportSync()
func (*MetricsCache) ResetCache ¶
func (c *MetricsCache) ResetCache()
type OpaDataClient ¶
type OpaDataClient interface { AddData(ctx context.Context, data interface{}) (*types.Responses, error) RemoveData(ctx context.Context, data interface{}) (*types.Responses, error) }
OpaDataClient is an interface for caching data.
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.