node

package
v0.0.14-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 38 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 node transports the finite sandbox Provider contract. Core remains the sole lifecycle owner; this package never retries a mutation or schedules work.

Index

Constants

View Source
const MaxControlFrameBytes = 32 * 1024
View Source
const MaxFrameBytes = 72 * 1024 * 1024
View Source
const ProtocolVersion = 11

Variables

View Source
var ErrAuthentication = errors.New("sandbox node authentication rejected")
View Source
var ErrUnavailable = errors.New("sandbox node unavailable")

Functions

func Run

func Run(ctx context.Context, config AgentConfig) error

Run owns one persistent node identity and reconnects its transport only. It never resends a Provider request. The bounded worker outlives each connection.

Types

type AgentConfig

type AgentConfig struct {
	Generations    *GenerationManager
	CoreURL        string
	StateDirectory string
	Identity       Identity
	Credential     string
	// Dialer is optional, primarily for an operator-supplied TLS trust configuration.
	Dialer *websocket.Dialer
}

type GenerationManager

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

GenerationManager owns local providers, preparation and all queued/in-flight references. Wire metadata is sparse; only correlated Core grants call Drop.

func NewGenerationManager

func NewGenerationManager(ctx context.Context, options GenerationManagerOptions) (*GenerationManager, error)

func (*GenerationManager) Acquire

func (m *GenerationManager) Acquire(generation uint64) (sandbox.SandboxProvider, bool, func(), error)

Acquire is called before queue admission, so queued work also prevents GC.

func (*GenerationManager) Close

func (m *GenerationManager) Close()

func (*GenerationManager) Deployment

func (m *GenerationManager) Deployment(value sandbox.NodeDeployment) error

func (*GenerationManager) Drop

func (*GenerationManager) Ready

func (m *GenerationManager) Ready(generation uint64) bool

func (*GenerationManager) Retained

func (m *GenerationManager) Retained(after uint64) []sandbox.GenerationReference

func (*GenerationManager) Statuses

func (m *GenerationManager) Statuses() []sandbox.GenerationStatus

type GenerationManagerOptions

type GenerationManagerOptions struct {
	Initial []GenerationProvider
	Recover []sandbox.GenerationReference
	Prepare func(context.Context, uint64, string) (GenerationProvider, error)
	Remove  func(context.Context, GenerationProvider) error
}

type GenerationProvider

type GenerationProvider struct {
	Generation          uint64
	SpecificationDigest string
	Provider            sandbox.SandboxProvider
	Probe               func(context.Context) (*sandbox.CheckpointCompatibility, error)
	// Quiescent reports that no helper outlived its canceled caller; nil
	// means always quiescent.
	Quiescent func() bool
	Close     func()
}

type Health

type Health struct {
	Generations          []sandbox.GenerationStatus `json:"generations,omitempty"`
	ObservedAt           time.Time                  `json:"observed_at"`
	ActiveOperations     int                        `json:"active_operations"`
	CPUCount             *int64                     `json:"cpu_count,omitempty"`
	CPUUtilization       *float64                   `json:"cpu_utilization"`
	TotalMemoryBytes     *int64                     `json:"total_memory_bytes"`
	EffectiveCPUCores    *float64                   `json:"effective_cpu_cores"`
	AvailableMemoryBytes *int64                     `json:"available_memory_bytes,omitempty"`
	AvailableDiskBytes   *int64                     `json:"available_disk_bytes,omitempty"`
}

type Hub

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

func NewHub

func NewHub(options HubOptions) *Hub

func (*Hub) Close

func (h *Hub) Close()

func (*Hub) Disconnect

func (h *Hub) Disconnect(id string)

func (*Hub) GenerationProvider

func (h *Hub) GenerationProvider(declared providercontract.Operations, resolve func(context.Context, sandbox.Reference) (string, uint64, error)) sandbox.SandboxProvider

GenerationProvider routes every operation with allocation-owned generation, distinct from the request's compute generation. declared is the kind's registered operations.

func (*Hub) Online

func (h *Hub) Online(id string) bool

func (*Hub) Proxy

func (h *Hub) Proxy(id string, declared providercontract.Operations, generation uint64) sandbox.SandboxProvider

Proxy binds a fixed node and deployment generation explicitly.

func (*Hub) ServeHTTP

func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HubOptions

type HubOptions struct {
	Generations  func(context.Context, Identity, string, uint64, Health) error
	Retention    func(context.Context, Identity, string, uint64, []sandbox.GenerationReference) (sandbox.NodeDeployment, []sandbox.GenerationRetention, error)
	Authenticate func(context.Context, string, string) (Identity, error)
	OwnerEpoch   func(context.Context) (uint64, error)
	Connected    func(context.Context, Identity, string, uint64) error
	Disconnected func(context.Context, Identity, string, uint64)
}

type Identity

type Identity struct {
	SpecificationDigest  string `json:"specification_digest"`
	DeploymentGeneration uint64 `json:"deployment_generation"`
	NodeID               string `json:"node_id"`
	InstallationID       string `json:"installation_id"`
	Provider             string `json:"provider"`
	BackendFingerprint   string `json:"backend_fingerprint"`
	MaxActive            int    `json:"max_active"`
	MaxRetained          int    `json:"max_retained"`
}

type StoredIdentity

type StoredIdentity struct {
	Identity   Identity `json:"identity"`
	Credential string   `json:"credential"`
	CoreURL    string   `json:"core_url"`
	OwnerEpoch uint64   `json:"owner_epoch"`
}

func Enroll

func Enroll(ctx context.Context, coreURL, dir, token string, input machineapi.NodeEnrollment) (StoredIdentity, error)

Enroll consumes a short-lived enrollment token. InitIdentity must have been called with the local provider identity before invoking this function.

func InitIdentity

func InitIdentity(dir, coreURL string, identity Identity) (StoredIdentity, error)

InitIdentity creates the credential before any enrollment request. A lost enrollment response can therefore be recovered by authenticating this identity.

func RefreshIdentity

func RefreshIdentity(ctx context.Context, dir string) (StoredIdentity, error)

RefreshIdentity reads approved capacity using the retained credential before reconnecting. Core remains authoritative after an administrator changes it.

Jump to

Keyboard shortcuts

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