Versions in this module Expand all Collapse all v1 v1.4.0 Oct 20, 2026 Changes in this version + var ErrInstanceAlreadyExists = errors.New("service instance already exists") + var ErrInstanceDraining = errors.New("service instance is currently draining") + var ErrInstanceNotFound = errors.New("service instance not found") + var ErrInstanceTerminated = errors.New("service instance is terminated") + var ErrInvalidServiceSpec = errors.New("invalid agent service specification") + var ErrMaxRestartsExceeded = errors.New("maximum restart retries exceeded") + var ErrNoHealthyInstance = errors.New("no healthy service instance available") + var ErrNoPreviousVersion = errors.New("no previous service version recorded for rollback") + var ErrRolloutFailed = errors.New("rollout upgrade failed") + var ErrRolloutInProgress = errors.New("rollout upgrade already in progress") + var ErrServiceAlreadyExists = errors.New("agent service already exists") + var ErrServiceNotFound = errors.New("agent service not found") + var ErrServiceTerminated = errors.New("agent service is terminated") + type AllServicesStore interface + ListAllServices func(context.Context) ([]*Service, error) + type BackoffConfig struct + Factor float64 + InitialInterval time.Duration + MaxInterval time.Duration + MaxRetries int + func DefaultBackoffConfig() BackoffConfig + func (b BackoffConfig) CalculateDelay(restartCount int) time.Duration + type HealthConfig struct + CheckInterval time.Duration + HeartbeatTTL time.Duration + UnhealthyThreshold int + func DefaultHealthConfig() HealthConfig + type Instance struct + Address ipc.AgentAddress + AgentID string + AgentVersion string + ConsecutiveFailures int + CreatedAt time.Time + DrainDeadline *time.Time + DrainingAt *time.Time + ExitCode int + ExitReason string + FencingToken uint64 + ID string + LastHeartbeat time.Time + LaunchSpec json.RawMessage + Namespace string + NextRestartAt *time.Time + Phase InstancePhase + RestartCount int + RuntimeClass string + ServiceID string + TaskID *uuid.UUID + TenantID string + TerminatedAt *time.Time + UpdatedAt time.Time + func (inst *Instance) IsActive() bool + func (inst *Instance) IsDraining() bool + func (inst *Instance) IsHealthy() bool + func (inst *Instance) IsRecovering() bool + func (inst *Instance) IsTerminal() bool + type InstancePhase string + const InstanceCreated + const InstanceDegraded + const InstanceDraining + const InstanceFailed + const InstanceRecovering + const InstanceRunning + const InstanceStarting + const InstanceStopped + const InstanceStopping + type InstanceSpawner interface + SpawnInstance func(ctx context.Context, svc *Service, inst *Instance) error + StopInstance func(ctx context.Context, svc *Service, inst *Instance) error + type MemoryStore struct + func NewMemoryStore() *MemoryStore + func NewMemoryStoreWithClock(clock func() time.Time) *MemoryStore + func (m *MemoryStore) CreateInstance(ctx context.Context, inst *Instance) error + func (m *MemoryStore) CreateService(ctx context.Context, svc *Service) error + func (m *MemoryStore) DeleteInstance(ctx context.Context, tenantID, serviceID, instanceID string) error + func (m *MemoryStore) DeleteService(ctx context.Context, tenantID, serviceID string) error + func (m *MemoryStore) GetInstance(ctx context.Context, tenantID, serviceID, instanceID string) (*Instance, error) + func (m *MemoryStore) GetService(ctx context.Context, tenantID, serviceID string) (*Service, error) + func (m *MemoryStore) GetServiceByName(ctx context.Context, tenantID, namespace, name string) (*Service, error) + func (m *MemoryStore) ListAllInstances(ctx context.Context, tenantID string) ([]*Instance, error) + func (m *MemoryStore) ListAllServices(ctx context.Context) ([]*Service, error) + func (m *MemoryStore) ListInstances(ctx context.Context, tenantID, serviceID string) ([]*Instance, error) + func (m *MemoryStore) ListServices(ctx context.Context, tenantID, namespace string) ([]*Service, error) + func (m *MemoryStore) UpdateInstance(ctx context.Context, inst *Instance) error + func (m *MemoryStore) UpdateService(ctx context.Context, svc *Service) error + type MockSpawner struct + OnSpawn func(ctx context.Context, svc *Service, inst *Instance) error + OnStop func(ctx context.Context, svc *Service, inst *Instance) error + Spawned map[string]*Instance + Stopped map[string]*Instance + func NewMockSpawner() *MockSpawner + func (m *MockSpawner) SpawnCount() int + func (m *MockSpawner) SpawnInstance(ctx context.Context, svc *Service, inst *Instance) error + func (m *MockSpawner) StopCount() int + func (m *MockSpawner) StopInstance(ctx context.Context, svc *Service, inst *Instance) error + type Option func(*Supervisor) + func WithClock(clock func() time.Time) Option + func WithIPCService(ipcSvc *ipc.Service) Option + func WithMailbox(mailbox ipc.Mailbox) Option + func WithSpawner(spawner InstanceSpawner) Option + type ResourceRequirements struct + CPU string + LLMSlots int + Memory string + type RestartPolicy string + const RestartAlways + const RestartNever + const RestartOnFailure + type RolloutConfig struct + MaxSurge int + MaxUnavailable int + MinReadyTime time.Duration + func DefaultRolloutConfig() RolloutConfig + type Router struct + func NewRouter(supervisor *Supervisor, store Store) *Router + func (r *Router) ResolveAddress(ctx context.Context, target ipc.AgentAddress) (ipc.AgentAddress, error) + type Service struct + AgentID string + CreatedAt time.Time + ID string + Name string + Namespace string + Spec ServiceSpec + Status ServiceStatus + TenantID string + UpdatedAt time.Time + func (s *Service) LogicalAddress() ipc.AgentAddress + func (s *Service) Validate() error + type ServiceLockStore interface + WithServiceLock func(context.Context, string, string, func(Store) error) error + type ServicePhase string + const ServiceActive + const ServiceDegraded + const ServiceFailed + const ServicePending + const ServiceSuspended + const ServiceTerminated + type ServiceSpec struct + AgentVersion string + AgentVersionRef string + AutoWake bool + Backoff BackoffConfig + DrainTimeout time.Duration + Health HealthConfig + Labels map[string]string + Replicas int + Resources ResourceRequirements + RestartPolicy RestartPolicy + Rollout RolloutConfig + RuntimeClass string + ScaleToZeroTTL time.Duration + WorkloadSpec json.RawMessage + func (s *ServiceSpec) Validate() error + type ServiceStatus struct + ActiveVersion string + AvailableReplicas int + CurrentReplicas int + DesiredReplicas int + LastTransitionAt time.Time + Message string + Phase ServicePhase + PreviousVersion string + ReadyReplicas int + RestartCount int + UpdatedReplicas int + type Store interface + CreateInstance func(ctx context.Context, inst *Instance) error + CreateService func(ctx context.Context, svc *Service) error + DeleteInstance func(ctx context.Context, tenantID, serviceID, instanceID string) error + DeleteService func(ctx context.Context, tenantID, serviceID string) error + GetInstance func(ctx context.Context, tenantID, serviceID, instanceID string) (*Instance, error) + GetService func(ctx context.Context, tenantID, serviceID string) (*Service, error) + GetServiceByName func(ctx context.Context, tenantID, namespace, name string) (*Service, error) + ListAllInstances func(ctx context.Context, tenantID string) ([]*Instance, error) + ListInstances func(ctx context.Context, tenantID, serviceID string) ([]*Instance, error) + ListServices func(ctx context.Context, tenantID, namespace string) ([]*Service, error) + UpdateInstance func(ctx context.Context, inst *Instance) error + UpdateService func(ctx context.Context, svc *Service) error + type Supervisor struct + func NewSupervisor(store Store, opts ...Option) *Supervisor + func (s *Supervisor) CreateService(ctx context.Context, svc *Service) (*Service, error) + func (s *Supervisor) DeleteService(ctx context.Context, tenant, id string) error + func (s *Supervisor) DrainInstance(ctx context.Context, tenant, service, instance string, timeout time.Duration) error + func (s *Supervisor) GetService(ctx context.Context, tenantID, serviceID string) (*Service, error) + func (s *Supervisor) ListServices(ctx context.Context, tenantID, namespace string) ([]*Service, error) + func (s *Supervisor) Reconcile(ctx context.Context, tenantID string) error + func (s *Supervisor) ReconcileService(ctx context.Context, svc *Service) error + func (s *Supervisor) RecordHeartbeat(ctx context.Context, tenant, service, instance string) error + func (s *Supervisor) ReportInstanceExit(ctx context.Context, tenant, service, instance string, code int, reason string) error + func (s *Supervisor) RestartService(ctx context.Context, tenant, id string) error + func (s *Supervisor) RollbackService(ctx context.Context, tenant, id string) (*Service, error) + func (s *Supervisor) RolloutUpgrade(ctx context.Context, tenant, id, version string) (*Service, error) + func (s *Supervisor) ScaleService(ctx context.Context, tenant, id string, replicas int) (*Service, error) + func (s *Supervisor) StopService(ctx context.Context, tenant, id string) error + func (s *Supervisor) UpdateService(ctx context.Context, svc *Service) (*Service, error) + type TaskExecution struct + Attempt *kernelstore.Attempt + Lease *kernelstore.Lease + Task kernelstore.Task + type TaskRepository interface + CreateTask func(context.Context, kernelstore.CreateTaskInput) (kernelstore.CreateTaskResult, error) + GetAgentVersionByRef func(context.Context, string, string) (kernelstore.AgentVersion, error) + GetServiceTaskExecution func(context.Context, string, uuid.UUID) (TaskExecution, error) + GetTask func(context.Context, string, uuid.UUID) (kernelstore.Task, error) + RequestTaskCancellation func(context.Context, string, uuid.UUID, int64) (kernelstore.Task, error) + type TaskSpawner struct + func NewTaskSpawner(repository TaskRepository) *TaskSpawner + func (p *TaskSpawner) PrepareInstance(svc *Service, inst *Instance) + func (p *TaskSpawner) Rebind(store Store) InstanceSpawner + func (p *TaskSpawner) RefreshInstance(ctx context.Context, svc *Service, inst *Instance) error + func (p *TaskSpawner) SpawnInstance(ctx context.Context, svc *Service, inst *Instance) error + func (p *TaskSpawner) StopInstance(ctx context.Context, svc *Service, inst *Instance) error + func (p *TaskSpawner) ValidateService(ctx context.Context, svc *Service) error