scaling

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package scaling provides the autoscaling capability for Vertex objects.

A workqueue is implemented in this package to watch vertices in the cluster, calculate the desired replica number for each of them periodically, and patch the vertex spec.

Function StartWatching() and StopWatching() are also provided in the package, so that vertices can be added into and removed from the workqueue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyOfVertex

func KeyOfVertex(vertex dfv1.Vertex) string

KeyOfVertex returns the unique key of a vertex

Types

type Option

type Option func(*options)

func WithBackPressureThreshold

func WithBackPressureThreshold(n float64) Option

WithBackPressureThreshold sets the threshold of considering there's back pressure, a float value less than 1.

func WithClientsCacheSize added in v0.9.0

func WithClientsCacheSize(n int) Option

WithClientsCacheSize sets the size of the daemon clients cache.

func WithTaskInterval

func WithTaskInterval(n int) Option

WithTaskInterval sets the interval of picking up a task from the work queue.

func WithWorkers

func WithWorkers(n int) Option

WithWorkers sets the number of workers working on autoscaling.

type Scaler

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

func NewScaler

func NewScaler(client client.Client, opts ...Option) *Scaler

NewScaler returns a Scaler instance.

func (*Scaler) Contains

func (s *Scaler) Contains(key string) bool

Contains returns if the Scaler contains the key.

func (*Scaler) Length

func (s *Scaler) Length() int

Length returns how many vertices are being watched for autoscaling

func (*Scaler) Start

func (s *Scaler) Start(ctx context.Context) error

Start function starts the autoscaling worker group. Each worker keeps picking up scaling tasks (which contains vertex keys) to calculate the desired replicas, and patch the vertex spec with the new replica number if needed.

func (*Scaler) StartWatching

func (s *Scaler) StartWatching(key string)

StartWatching put a key (namespace/name) into the Scaler

func (*Scaler) StopWatching

func (s *Scaler) StopWatching(key string)

StopWatching stops autoscaling on the key (namespace/name)

Jump to

Keyboard shortcuts

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