kubernetesk8s.io/kubernetes/pkg/proxy/runner Index | Files

package runner

import "k8s.io/kubernetes/pkg/proxy/runner"

Index

Types

type BoundedFrequencyRunner

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

BoundedFrequencyRunner manages runs of a user-provided work function.

func NewBoundedFrequencyRunner

func NewBoundedFrequencyRunner(name string, fn func() error, minInterval, retryInterval, maxInterval time.Duration) *BoundedFrequencyRunner

NewBoundedFrequencyRunner creates and returns a new BoundedFrequencyRunner. This runner manages the execution frequency of the provided function `fn`.

The runner guarantees two properties:

  1. Minimum Interval (`minInterval`): At least `minInterval` must pass between the *completion* of one execution and the *start* of the next. Calls to `Run()` during this cooldown period are coalesced and deferred until the interval expires. This prevents burst executions.
  2. Maximum Interval (`maxInterval`): The function `fn` is guaranteed to run at least once per `maxInterval`, ensuring periodic execution even without explicit `Run()` calls (e.g., for refreshing state).

`maxInterval` must be greater than or equal to `minInterval`; otherwise, this function will panic.

If `fn` returns an error, then it will be run again no later than `retryInterval` (unless another trigger, like `Run()` or `maxInterval`, causes it to run sooner). Any successful run will abort the retry attempt.

func (*BoundedFrequencyRunner) Loop

func (bfr *BoundedFrequencyRunner) Loop(stop <-chan struct{})

Loop handles the periodic timer and run requests. This is expected to be called as a goroutine.

func (*BoundedFrequencyRunner) Run

func (bfr *BoundedFrequencyRunner) Run()

Run the work function as soon as possible. If this is called while Loop is not running, the call may be deferred indefinitely. Once there is a queued request to call the work function, further calls to Run() will have no effect until after it runs.

Source Files

bounded_frequency_runner.go

Version
v1.34.0-alpha.3
Published
Jul 9, 2025
Platform
js/wasm
Imports
5 packages
Last checked
29 seconds ago

Tools for package owners.