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 MonoVertex objects.

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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyOfMonoVertex

func KeyOfMonoVertex(monoVtx dfv1.MonoVertex) string

KeyOfMonoVertex returns the unique key of a MonoVertex

Types

type Option

type Option func(*options)

func WithClientsCacheSize

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 mono vertex keys) to calculate the desired replicas, and patch the mono 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