scaler

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scaler

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

Scaler implements listener.Scaler to handle scaling decisions and manage runner lifecycle via a pluggable RunnerBackend.

func NewScaler

func NewScaler(scaleSetID, minRunners, maxRunners int, b backend.RunnerBackend, client ScalesetAPI, logger *slog.Logger) *Scaler

NewScaler creates a new Scaler instance.

func (*Scaler) HandleDesiredRunnerCount

func (s *Scaler) HandleDesiredRunnerCount(ctx context.Context, count int) (int, error)

HandleDesiredRunnerCount scales runners up to match demand. Scale down is handled naturally via HandleJobCompleted.

func (*Scaler) HandleJobCompleted

func (s *Scaler) HandleJobCompleted(ctx context.Context, jobInfo *scaleset.JobCompleted) error

HandleJobCompleted removes the runner after job finishes.

func (*Scaler) HandleJobStarted

func (s *Scaler) HandleJobStarted(ctx context.Context, jobInfo *scaleset.JobStarted) error

HandleJobStarted marks a runner as busy when a job is assigned.

func (*Scaler) RunnerCounts

func (s *Scaler) RunnerCounts() (idle, busy int)

RunnerCounts returns the number of idle and busy runners.

func (*Scaler) Shutdown

func (s *Scaler) Shutdown(ctx context.Context)

Shutdown force-removes all managed runners.

type ScalesetAPI

type ScalesetAPI interface {
	GenerateJitRunnerConfig(ctx context.Context, setting *scaleset.RunnerScaleSetJitRunnerSetting, scaleSetID int) (*scaleset.RunnerScaleSetJitRunnerConfig, error)
}

ScalesetAPI abstracts the scaleset client methods used by Scaler.

Jump to

Keyboard shortcuts

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