Documentation
¶
Overview ¶
Package control owns per-device control-session lifecycles and serialization. It deliberately knows nothing about MCP, CLI, or the JetKVM wire protocol.
Index ¶
- Constants
- Variables
- type Config
- type ExecuteFunc
- type Handle
- type HandleID
- type HandleState
- type Lock
- type Locker
- type OpenRequest
- type Ownership
- type Ref
- type Registry
- func (r *Registry) Close(ctx context.Context, deviceID domain.DeviceID, ref Ref) (Handle, error)
- func (r *Registry) Drain(ctx context.Context) error
- func (r *Registry) Execute(ctx context.Context, deviceID domain.DeviceID, ref Ref, capability string, ...) error
- func (r *Registry) Get(ctx context.Context, deviceID domain.DeviceID, ref Ref) (Snapshot, error)
- func (r *Registry) Open(ctx context.Context, request OpenRequest) (Handle, error)
- func (r *Registry) Quiescent(ctx context.Context) (bool, error)
- func (r *Registry) Reconnect(ctx context.Context, deviceID domain.DeviceID, ref Ref) (Handle, error)
- func (r *Registry) State() TransportState
- type Session
- type SessionFactory
- type SessionState
- type Snapshot
- type TransportState
Constants ¶
Variables ¶
var ( ErrInvalidConfig = errors.New("invalid control configuration") ErrControlNotFound = errors.New("control handle was not found") ErrControlExpired = errors.New("control handle expired") ErrGenerationMismatch = errors.New("control generation mismatch") ErrControlBusy = errors.New("control is draining") ErrRegistryClosed = errors.New("control registry is closed") ErrCapabilityMissing = errors.New("control capability is unavailable") )
Functions ¶
This section is empty.
Types ¶
type ExecuteFunc ¶
ExecuteFunc runs inside the per-device write queue. The Session value is valid only for the duration of the callback and must not be retained.
type Handle ¶
type Handle struct {
ID HandleID
DeviceID domain.DeviceID
Generation uint64
Ownership Ownership
Capabilities []string
State HandleState
CreatedAt time.Time
LastUsedAt time.Time
IdleExpiresAt time.Time
AbsoluteExpiresAt time.Time
}
Handle identifies one generation of one device control session.
type HandleState ¶
type HandleState string
const ( HandleReady HandleState = "ready" HandleDraining HandleState = "draining" HandleExpired HandleState = "expired" HandleClosed HandleState = "closed" HandleFenced HandleState = "fenced" )
type Lock ¶
type Lock interface {
Release() error
}
Lock is held for the complete lifetime of a device session.
type Locker ¶
Locker prevents independent local processes from controlling one device at the same time.
type OpenRequest ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns one actor per stable device identity.
func NewRegistry ¶
func (*Registry) Drain ¶
Drain stops accepting new work, drains every per-device queue, closes owned sessions, and releases all cross-process locks.
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx context.Context, deviceID domain.DeviceID, ref Ref, capability string, execute ExecuteFunc) error
Execute serializes state-changing work for one device while allowing other device actors to progress independently.
func (*Registry) Quiescent ¶ added in v1.0.6
Quiescent queries actor-owned state. The caller must exclude new operations until its reconfiguration is complete; this is not a substitute for that gate.
func (*Registry) Reconnect ¶
func (r *Registry) Reconnect(ctx context.Context, deviceID domain.DeviceID, ref Ref) (Handle, error)
Reconnect replaces the protocol session, fences the old handle, and returns a new handle with a strictly greater generation.
func (*Registry) State ¶
func (r *Registry) State() TransportState
type Session ¶
Session is the protocol adapter resource owned by a DeviceActor. Concrete implementations may expose richer APIs to Execute callbacks.
type SessionFactory ¶
type SessionFactory interface {
Open(context.Context, domain.DeviceID, uint64, []string) (Session, error)
}
SessionFactory creates a fresh protocol session for one fenced generation.
type SessionState ¶
type SessionState string
const ( SessionAbsent SessionState = "absent" SessionOpening SessionState = "opening" SessionReady SessionState = "ready" SessionDraining SessionState = "draining" SessionClosing SessionState = "closing" SessionClosed SessionState = "closed" SessionUncertain SessionState = "uncertain" )
type Snapshot ¶
type Snapshot struct {
Transport TransportState
Session SessionState
Handle *Handle
}
Snapshot reports the three independent lifecycle state machines.
type TransportState ¶
type TransportState string
const ( TransportRunning TransportState = "running" TransportDraining TransportState = "draining" TransportClosed TransportState = "closed" )