scheduling

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package scheduling decides which worker should host an actor.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCapacity = errors.New("no free workers satisfy the constraints")

ErrNoCapacity is returned by Schedule when no free worker satisfies the constraints.

Functions

This section is empty.

Types

type Constraints

type Constraints struct {
	// SandboxClass must equal the worker's sandbox class. Snapshots are not
	// portable across sandbox classes, so this is never relaxed.
	SandboxClass string

	// TemplateSelector and ActorSelector must both match the worker's labels.
	TemplateSelector labels.Selector
	ActorSelector    labels.Selector

	// RequiredNodes, when non-empty, restricts placement to workers running
	// on one of these nodes. Used when the actor's latest snapshot is local
	// to specific node VMs.
	RequiredNodes []string

	// Limits are the actor's declared resource limits, named as a Worker names
	// the capacity it reports, so the two subtract.
	Limits *ateapipb.Resources
}

Constraints describes what a worker must satisfy to host an actor.

type Option

type Option func(*scheduler)

Option configures the Scheduler returned by New.

func WithIntn

func WithIntn(intn func(n int) int) Option

WithIntn overrides the random source used to pick among equally suitable workers. n is always >= 1.

func WithMeter

func WithMeter(meter metric.Meter) Option

WithMeter configures the meter used to create telemetry instruments for the scheduler. If meter is nil, the option is a no-op. If instrument creation fails, an error is explicitly logged.

type Scheduler

type Scheduler interface {
	// Schedule returns a free worker satisfying constraints.
	// Returns ErrNoCapacity when no free worker satisfies the requested constraints.
	Schedule(ctx context.Context, constraints Constraints) (*ateapipb.Worker, error)

	// Applies reports whether worker satisfies non-capacity constraints. Capacity
	// is excluded so an existing assignment does not make its Worker ineligible.
	Applies(worker *ateapipb.Worker, constraints Constraints) bool

	// HasRoom reports whether worker's remaining capacity admits one more actor
	// of this size, in every dimension. Independent of Applies.
	HasRoom(worker *ateapipb.Worker, constraints Constraints) bool
}

Scheduler answers placement questions against the current worker fleet.

func New

func New(source WorkerSource, opts ...Option) Scheduler

New returns a Scheduler placing onto workers reported by source.

type WorkerSource

type WorkerSource interface {
	Workers() ([]*ateapipb.Worker, error)
}

WorkerSource provides the whole fleet of workers.

Jump to

Keyboard shortcuts

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