Documentation
¶
Overview ¶
Package scheduler provides deterministic, explainable runtime placement.
Index ¶
- Variables
- func GuardProductionPoolSource(source PoolSource, devMode bool) error
- func WithParallelism(workers int) func(*Controller)
- func WithShard(index, count int) func(*Controller)
- type Controller
- type LeaseAwarePoolSource
- type Placement
- type PoolSource
- type Rejection
- type Result
- type RuntimePool
- type ScoreComponent
- type StaticPoolSource
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPoolSet = errors.New("runtime pool set is invalid")
var ErrNoPlacement = errors.New("no eligible runtime placement")
Functions ¶
func GuardProductionPoolSource ¶
func GuardProductionPoolSource(source PoolSource, devMode bool) error
GuardProductionPoolSource rejects a StaticPoolSource on a production startup path. The scheduler's authoritative capacity total lives in the durable capacity ledger; a StaticPoolSource sidesteps it, so a non-dev server that is (now or in future) handed one - directly or wrapped by a LeaseAwarePoolSource - fails closed rather than silently scheduling against unenforced capacity. devMode mirrors the -dev-mode acknowledgment that already gates seeding the mutable registry from a flat file.
func WithParallelism ¶
func WithParallelism(workers int) func(*Controller)
WithParallelism bounds concurrent per-task processing within one reconcile batch (default 4; 1 = serial).
func WithShard ¶
func WithShard(index, count int) func(*Controller)
WithShard confines this instance to one tenant-consistent claim shard (ADR-016): it claims only tasks whose tenant maps to index of count. Count 0 disables sharding. Every controller instance must share the same count.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(repository store.ControlStore, pools PoolSource, ownerID string, batch int, claimTTL, leaseTTL time.Duration) *Controller
type LeaseAwarePoolSource ¶
type LeaseAwarePoolSource struct {
// contains filtered or unexported fields
}
LeaseAwarePoolSource overlays lease-derived runtime health onto a static pool configuration: a pool is ready only when its static configuration says ready AND its runtime instance is presumed alive by recent lease heartbeats. Placement therefore rejects pools whose worker stopped renewing its lease instead of scheduling a task that would be stranded until lease-expiry recovery. An instance ID missing from the health result is treated as unhealthy (fail-closed).
func NewLeaseAwarePoolSource ¶
func NewLeaseAwarePoolSource(static PoolSource, health store.PoolHealthStore, freshness time.Duration) *LeaseAwarePoolSource
func (*LeaseAwarePoolSource) ListRuntimePools ¶
func (s *LeaseAwarePoolSource) ListRuntimePools(ctx context.Context, tenantID string) ([]RuntimePool, error)
type Placement ¶
type Placement struct {
Pool RuntimePool `json:"pool"`
Score float64 `json:"score"`
Components []ScoreComponent `json:"components"`
}
type PoolSource ¶
type PoolSource interface {
ListRuntimePools(context.Context, string) ([]RuntimePool, error)
}
type Result ¶
type Result struct {
Placement Placement `json:"placement"`
// Candidates is the full score-ranked placement list. Placement is the
// first entry; the scheduler walks the remaining entries in order when
// a higher-ranked pool loses the transactional capacity reservation.
Candidates []Placement `json:"candidates"`
Rejected []Rejection `json:"rejected"`
}
type RuntimePool ¶
type RuntimePool struct {
ID string `json:"id"`
TenantIDs []string `json:"tenantIds"`
RuntimeClass string `json:"runtimeClass"`
RuntimeInstanceID string `json:"runtimeInstanceId"`
Region string `json:"region"`
DataResidency string `json:"dataResidency"`
Ready bool `json:"ready"`
// Status separates health from operator intent. Empty/ACTIVE accepts new
// work; CORDONED and DRAINING preserve existing leases but reject placement.
Status string `json:"status,omitempty"`
FailureDomain string `json:"failureDomain,omitempty"`
AvailableCPU int64 `json:"availableCpuMillis"`
AvailableMemory int64 `json:"availableMemoryMiB"`
AvailableLLMSlots int `json:"availableLlmSlots"`
// CapacityLedgerMissing marks a pool whose durable capacity ledger was
// never registered by the operator. Such pools fail placement closed
// instead of being treated as fully idle. Zero (the default) keeps
// statically configured pools schedulable.
CapacityLedgerMissing bool `json:"capacityLedgerMissing,omitempty"`
ArtifactRegions []string `json:"artifactRegions"`
CostWeight float64 `json:"costWeight"`
// Operators lists the operator subjects granted cordon/drain/activate
// authority on this pool. Usage visibility comes from TenantIDs; the
// two authorities are deliberately independent so a tenant of a shared
// pool cannot operate it.
Operators []string `json:"operators,omitempty"`
}
type ScoreComponent ¶
type StaticPoolSource ¶
type StaticPoolSource []RuntimePool
StaticPoolSource is an in-memory pool list for tests and local development. It is NOT a production capacity authority: it reports pools directly from a fixed slice and never consults the durable capacity ledger, so wiring it into a server bypasses the reservation invariant that keeps concurrent placement from over-committing a pool. Production builds the pool source from the durable registry (LeaseAwarePoolSource over the store); GuardProductionPoolSource fails a non-dev server that is handed a StaticPoolSource.
func (StaticPoolSource) ListRuntimePools ¶
func (s StaticPoolSource) ListRuntimePools(_ context.Context, tenantID string) ([]RuntimePool, error)