scheduling

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 9 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 worker that meets the constraints has room")

ErrNoCapacity is returned by Schedule when no worker that meets the constraints has room. The cause can be full workers, or no worker that meets the constraints at all.

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

	// RequiredRuntime, when non-nil, restricts placement to workers whose
	// DefaultRuntime or RestorableRuntimes can restore a snapshot stamped with
	// this runtime.
	RequiredRuntime *ateapipb.SandboxRuntime

	// 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 sample candidate pairs: when n >= 2 candidates exist, Schedule calls intn(n) and then intn(n-1).

type Scheduler

type Scheduler interface {
	// Schedule returns a worker that meets constraints and has room.
	// Returns ErrNoCapacity when no worker that meets constraints has room.
	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