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
- Variables
- func Run(ctx context.Context, config AgentConfig) error
- type AgentConfig
- type GenerationManager
- func (m *GenerationManager) Acquire(generation uint64) (sandbox.SandboxProvider, bool, func(), error)
- func (m *GenerationManager) Close()
- func (m *GenerationManager) Deployment(value sandbox.NodeDeployment) error
- func (m *GenerationManager) Drop(ctx context.Context, grant sandbox.GenerationRetention) error
- func (m *GenerationManager) Ready(generation uint64) bool
- func (m *GenerationManager) Retained(after uint64) []sandbox.GenerationReference
- func (m *GenerationManager) Statuses() []sandbox.GenerationStatus
- type GenerationManagerOptions
- type GenerationProvider
- type Health
- type Hub
- func (h *Hub) Close()
- func (h *Hub) Disconnect(id string)
- func (h *Hub) GenerationProvider(declared providercontract.Operations, ...) sandbox.SandboxProvider
- func (h *Hub) Online(id string) bool
- func (h *Hub) Proxy(id string, declared providercontract.Operations, generation uint64) sandbox.SandboxProvider
- func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type HubOptions
- type Identity
- type StoredIdentity
Constants ¶
const MaxControlFrameBytes = 32 * 1024
const MaxFrameBytes = 72 * 1024 * 1024
const ProtocolVersion = 11
Variables ¶
var ErrAuthentication = errors.New("sandbox node authentication rejected")
Functions ¶
Types ¶
type AgentConfig ¶
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 (m *GenerationManager) Drop(ctx context.Context, grant sandbox.GenerationRetention) error
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) Disconnect ¶
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) Proxy ¶
func (h *Hub) Proxy(id string, declared providercontract.Operations, generation uint64) sandbox.SandboxProvider
Proxy binds a fixed node and deployment generation explicitly.
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.