placement

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package placement decides whether the sandbox deployment admits new hosted work and which node receives it. Its rules are pure: they read the deployment and node facts the caller loads under the deployment lock, the provider declarations and the installation public URL, and do no I/O. The caller applies what they decide in the same transaction.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResetAdmission rejects new hosted work while a sandbox reset pauses
	// admission.
	ErrResetAdmission = errors.New("hosted admission is paused for a sandbox reset")
	// ErrAdmissionClosed rejects new hosted work that the deployment cannot
	// admit: paused for maintenance, without a valid specification, or for
	// another installation.
	ErrAdmissionClosed = errors.New("environment is no longer available")
	// ErrPublicURLUnreachable rejects selection and admission when the provider
	// requires a reachable public origin and the installation is loopback.
	ErrPublicURLUnreachable = errors.New("This sandbox provider needs a reachable HTTPS public URL before they can connect to Core.")
	// ErrNodesPreparing rejects placement while no node serves the target
	// generation and at least one is preparing it.
	ErrNodesPreparing = errors.New("sandbox nodes are preparing the target generation")
	// ErrNodeUnavailable reports a sandbox node that is offline, unready or
	// full, or no node at all.
	ErrNodeUnavailable = errors.New("sandbox node unavailable")
)

Functions

func CheckReserved

func CheckReserved(reserved Reserved) error

CheckReserved admits an allocation on the node placement its Session reserved: the placement must be unreleased and its node available.

func CheckRestore

func CheckRestore(restore Restore) error

CheckRestore admits restoring suspended compute on its original node: the node must be online, ready for the allocation's generation and below its active capacity. Restore never selects another node.

func LoopbackOrigin

func LoopbackOrigin(value string) bool

LoopbackOrigin reports whether a validated origin names a loopback host, which nothing outside the Core host can reach.

Types

type Declarations

type Declarations interface {
	// RequiresPublicOrigin reports whether the provider's guests must reach
	// Core at a public origin.
	RequiresPublicOrigin(provider string) (bool, error)
	// ValidateSpecification rejects a specification the provider cannot run.
	ValidateSpecification(provider string, spec sandbox.DeploymentSpec) error
}

Declarations are the provider declarations placement reads. *providers.Registry satisfies it.

type Deployment

type Deployment struct {
	// InstallationID is empty until an installation is claimed or configured.
	InstallationID  string
	Provider, Mode  string
	Generation      uint64
	WebManaged      bool
	AdmissionPaused bool
	// Resetting reports a sandbox reset in progress.
	Resetting     bool
	Specification json.RawMessage
}

Deployment is the deployment as placement reads it, loaded under the deployment lock.

type Node

type Node struct {
	ID                   string
	Online, ServingReady bool
	// ReadyGeneration is nil until the node serves a generation.
	ReadyGeneration        *uint64
	TargetState            string
	Active, Retained       int64
	MaxActive, MaxRetained int
	CoreURL                string
}

Node is one node of the installation with its presence and usage.

type Placement

type Placement struct {
	NodeID     string
	Generation uint64
}

Placement is the node and generation a new Session's Environment reserves.

type Reserved

type Reserved struct {
	NodeID     string
	Generation uint64
	Released   bool
	// Available reports that the node is connected, fresh and ready for the
	// reserved generation.
	Available bool
}

Reserved is the node placement a Session reserved for its Environment.

type Restore

type Restore struct {
	Node *Node
	// Generation is zero when the allocation has none.
	Generation      uint64
	GenerationReady bool
}

Restore is what restoring suspended compute on its node reads: the node, nil when the installation no longer has it, and whether the node is ready for the allocation's generation.

type Rules

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

Rules decides admission and placement for one installation. Its declarations and public URL never change after NewRules.

func NewRules

func NewRules(declarations Declarations, publicURL string) (*Rules, error)

NewRules returns the rules for the provider declarations and the installation public URL, which is empty when the installation has none.

func (*Rules) CheckAdmission

func (r *Rules) CheckAdmission(d Deployment, installation string) error

CheckAdmission admits new hosted work on the deployment. installation is the canonical installation the work was provisioned for, or empty for a new Session. An unclaimed deployment admits everything.

func (*Rules) CheckPublicOrigin

func (r *Rules) CheckPublicOrigin(provider string) error

CheckPublicOrigin rejects a provider that requires a reachable public origin while the installation public URL is loopback.

func (*Rules) DecidePlacement

func (r *Rules) DecidePlacement(d Deployment, nodes []Node) (*Placement, error)

DecidePlacement chooses the node a new Session's hosted Environment reserves, or nil when the deployment places no node: in direct mode and without a provider. It prefers the highest ready generation, then the fewest active sandboxes. A Web-managed installation places only on nodes enrolled with its public URL; restores still reach the others.

func (*Rules) PublicURL

func (r *Rules) PublicURL() string

PublicURL returns the installation public URL, OAC_PUBLIC_URL. Core derives every address it gives nodes, sandboxes and administrators from it.

Jump to

Keyboard shortcuts

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