scaler

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package scaler implements the listener.Scaler interface for ECS-based GitHub Actions runners. It handles scaling decisions, JIT config generation, and delegates ECS task management to the runner package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ECSScaler

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

ECSScaler implements listener.Scaler for ECS-based runners.

func NewECSScaler

func NewECSScaler(
	client ScaleSetClient,
	taskRunner TaskRunner,
	scaleSetID int,
	scaleSetName string,
	taskDefFamily string,
	config taskdef.ScaleSetConfig,
	logger *slog.Logger,
) *ECSScaler

NewECSScaler creates a new ECSScaler.

func (*ECSScaler) HandleDesiredRunnerCount

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

HandleDesiredRunnerCount is called on every poll cycle. It computes the target runner count (applying min/max bounds) and scales up if needed. Scale-down is handled naturally by ephemeral runners exiting after jobs.

func (*ECSScaler) HandleJobCompleted

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

HandleJobCompleted removes a runner from tracking. The ECS task will stop on its own since the runner is ephemeral.

func (*ECSScaler) HandleJobStarted

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

HandleJobStarted marks a runner as busy when it picks up a job.

type ScaleSetClient

type ScaleSetClient interface {
	GenerateJitRunnerConfig(ctx context.Context, setting *scaleset.RunnerScaleSetJitRunnerSetting, scaleSetID int) (*scaleset.RunnerScaleSetJitRunnerConfig, error)
	GetRunnerByName(ctx context.Context, name string) (*scaleset.RunnerReference, error)
	RemoveRunner(ctx context.Context, runnerID int64) error
}

ScaleSetClient is the subset of scaleset.Client that the scaler needs.

type TaskRunner

type TaskRunner interface {
	RunTask(ctx context.Context, input runner.RunTaskInput) (string, error)
	StopTask(ctx context.Context, taskARN, reason string) error
}

TaskRunner is the interface for managing ECS runner tasks.

Jump to

Keyboard shortcuts

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