assign

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 13 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 assign executes the coordinator's ModelAssignment pushes on the operator's terms (SPEC §4.1, §4.4; plan 05).

The mesh may fill this node with models — download, load, and later evict what it placed — but only inside the operator's consent:

  • the models mesh_managed switch (default on; off = decline all),
  • max_disk_mb (a placement that cannot fit even after evicting other mesh-placed models is declined, never forced),
  • pin (never evicted) and exclude (never assigned),
  • and the operator's own models, which the mesh cannot evict at all (cache entries carry an origin; only "mesh" ones are the mesh's).

Every decision is reported back over the tunnel as a ModelState: "assigned" (accepted, queued), "downloading", "ready", "declined" (policy), "failed" (error), "evicted". The coordinator uses declined / failed to back off, and the heartbeat carries assigned/downloading so placement knows a replica is on its way.

Index

Constants

View Source
const (
	StateAssigned    = "assigned"
	StateDownloading = "downloading"
	StateReady       = "ready"
	StateDeclined    = "declined"
	StateFailed      = "failed"
	StateEvicted     = "evicted"
)

States reported to the coordinator and shown in the local API.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pending

type Pending struct {
	ID    string    `json:"id"`
	State string    `json:"state"`
	Since time.Time `json:"since"`
	// Error is the failure or refusal reason (failed/declined only).
	Error string `json:"error,omitempty"`
}

Pending is one assignment the node is working on or has concluded.

func (Pending) Describe

func (p Pending) Describe() string

Describe renders a pending record for logs/UI.

type Policy

type Policy struct {
	MeshManaged bool
	Exclude     []string
	Pinned      []string
}

Policy is the operator's standing consent, read fresh per decision so a dashboard toggle applies to the next assignment without a restart.

type Service

type Service struct {
	Ops *modelops.Service
	Mgr *models.Manager
	Eng *engine.Engine
	// OnBattery reports power state; downloads wait while true.
	OnBattery func() bool
	// Policy returns the current consent. Required.
	Policy func() Policy
	// Events receives model_assignment events. May be nil.
	Events *events.Hub
	Log    *slog.Logger
	// contains filtered or unexported fields
}

Service applies assignments. Nil Ops (mock runtime) declines everything with a clear reason so the coordinator backs off instead of retrying.

func (*Service) Apply

func (s *Service) Apply(ctx context.Context, ma *tunnelv1.ModelAssignment)

Apply handles one ModelAssignment: evictions first (they free the disk the assignments need), then admission of each assignment under the policy. Idempotent: a repeated push for a model already ready or in flight is acknowledged, not restarted.

func (*Service) Get

func (s *Service) Get(id string) (Pending, bool)

Get returns one tracked assignment.

func (*Service) Pending

func (s *Service) Pending() []Pending

Pending returns every tracked assignment (local API), sorted by id.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run starts the worker; returns when ctx ends.

func (*Service) SetReporter

func (s *Service) SetReporter(fn func(*typesv1.ModelState) error)

SetReporter installs the tunnel send used for ModelStateUpdate messages (swapped on every (re)connect). Reports while disconnected are dropped; the next Hello/heartbeat carries the live states anyway.

func (*Service) States

func (s *Service) States() []*typesv1.ModelState

States returns the in-flight assignments for Hello/heartbeat model lists (assigned + downloading only; failures/refusals are one-shot reports, otherwise the coordinator would read every heartbeat as a fresh one).

Jump to

Keyboard shortcuts

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