controller

package
v3.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImportable = errors.New("requested image cannot be imported")

Functions

This section is empty.

Types

type ImageStreamController

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

func NewImageStreamController

func NewImageStreamController(client imageclient.Interface, informer imageinformer.ImageStreamInformer) *ImageStreamController

NewImageStreamController returns a new image stream import controller.

func (*ImageStreamController) Run

func (c *ImageStreamController) Run(workers int, stopCh <-chan struct{})

Run begins watching and syncing.

func (*ImageStreamController) SetNotifier

func (c *ImageStreamController) SetNotifier(n Notifier)

type Notifier

type Notifier interface {
	// Importing is invoked when the controller is going to import an image stream
	Importing(stream *imageapi.ImageStream)
}

Notifier provides information about when the controller makes a decision

type ScheduledImageStreamController

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

func NewScheduledImageStreamController

NewScheduledImageStreamController returns a new scheduled image stream import controller.

func (*ScheduledImageStreamController) Importing

func (s *ScheduledImageStreamController) Importing(stream *imageapi.ImageStream)

Importing is invoked when the controller decides to import a stream in order to push back the next schedule time.

func (*ScheduledImageStreamController) Run

func (s *ScheduledImageStreamController) Run(stopCh <-chan struct{})

Run begins watching and syncing.

type ScheduledImageStreamControllerOptions

type ScheduledImageStreamControllerOptions struct {
	Resync time.Duration

	// Enabled indicates that the scheduled imports for images are allowed.
	Enabled bool

	// DefaultBucketSize is the default bucket size used by QPS.
	DefaultBucketSize int

	// MaxImageImportsPerMinute sets the maximum number of simultaneous image imports per
	// minute.
	MaxImageImportsPerMinute int
}

ImageStreamControllerOptions represents a configuration for the scheduled image stream import controller.

func (ScheduledImageStreamControllerOptions) Buckets

Buckets returns the bucket size calculated based on the resync interval of the scheduled image import controller. For resync interval bigger than our the bucket size is doubled, for resync lower then 10 minutes bucket size is set to a half of the default size.

func (ScheduledImageStreamControllerOptions) BucketsToQPS

func (opts ScheduledImageStreamControllerOptions) BucketsToQPS() float32

BucketsToQPS converts the bucket size to QPS

func (ScheduledImageStreamControllerOptions) GetRateLimiter

GetRateLimiter returns a flowcontrol rate limiter based on the maximum number of imports (MaxImageImportsPerMinute) setting.

type Scheduler added in v3.7.0

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

Scheduler is a self-balancing, rate-limited, bucketed queue that can periodically invoke an action on all items in a bucket before moving to the next bucket. A ratelimiter sets an upper bound on the number of buckets processed per unit time. The queue has a key and a value, so both uniqueness and equality can be tested (key must be unique, value can carry info for the next processing). Items remain in the queue until removed by a call to Remove().

func NewScheduler added in v3.7.0

func NewScheduler(bucketCount int, bucketLimiter flowcontrol.RateLimiter, fn func(key, value interface{})) *Scheduler

NewScheduler creates a scheduler with bucketCount buckets, a rate limiter for restricting the rate at which buckets are processed, and a function to invoke when items are scanned in a bucket. TODO: remove DEBUG statements from this file once this logic has been adequately validated.

func (*Scheduler) Add added in v3.7.0

func (s *Scheduler) Add(key, value interface{})

Add places the key in the bucket with the least entries (except the current bucket). The key is used to determine uniqueness, while value can be used to associate additional data for later retrieval. An Add removes the previous key and value and will place the item in a new bucket. This allows callers to ensure that Add'ing a new item to the queue purges old versions of the item, while Remove can be conditional on removing only the known old version.

func (*Scheduler) Delay added in v3.7.0

func (s *Scheduler) Delay(key interface{})

Delay moves the key to the end of the chain if it exists.

func (*Scheduler) Len added in v3.7.0

func (s *Scheduler) Len() int

Len returns the number of scheduled items.

func (*Scheduler) Map added in v3.7.0

func (s *Scheduler) Map() map[interface{}]interface{}

Map returns a copy of the scheduler contents, but does not copy the keys or values themselves. If values and keys are not immutable, changing the value will affect the value in the queue.

func (*Scheduler) Remove added in v3.7.0

func (s *Scheduler) Remove(key, value interface{}) bool

Remove takes the key out of all buckets. If value is non-nil, the key will only be removed if it has the same value. Returns true if the key was removed.

func (*Scheduler) RunOnce added in v3.7.0

func (s *Scheduler) RunOnce()

RunOnce takes a single item out of the current bucket and processes it. If the bucket is empty, we wait for the rate limiter before returning.

func (*Scheduler) RunUntil added in v3.7.0

func (s *Scheduler) RunUntil(ch <-chan struct{})

RunUntil launches the scheduler until ch is closed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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