Documentation
¶
Overview ¶
Package microvm provides AppTheory's constrained AWS Lambda MicroVM runtime primitives.
Index ¶
- Constants
- func IsTerminalState(state LifecycleState) bool
- func SessionRegistryPartitionKey(tenantID, namespace string) string
- func SessionRegistrySortKey(sessionID string) string
- func SessionRegistryTableName() string
- func ValidateControllerContract(contract ControllerContract) error
- func ValidateEscapeHatches(escapeHatches EscapeHatches) error
- func ValidateLifecycleContract(contract LifecycleContract) error
- func ValidateSessionRecord(record SessionRecord) error
- func ValidateSessionRegistryContract(registry SessionRegistryContract) error
- func ValidateSessionRegistryRecord(record SessionRegistryRecord) error
- func ValidateSessionStatus(status SessionStatus) error
- type AuthContext
- type Client
- type Clock
- type Command
- type ContractKind
- type Controller
- type ControllerAuthContract
- type ControllerCommandContract
- type ControllerContract
- type ControllerEnvelopeContract
- type ControllerOption
- type ControllerRequest
- type ControllerResponse
- type CreateSessionInput
- type EscapeHatches
- type IDGenerator
- type LifecycleAdapter
- type LifecycleContract
- type LifecycleEvent
- type LifecycleHandler
- type LifecycleHook
- type LifecycleHookSpec
- type LifecycleOption
- type LifecycleResult
- type LifecycleState
- type LifecycleTransition
- type MemorySessionRegistry
- type RegistryClient
- func (c *RegistryClient) Create(ctx context.Context, input CreateSessionInput) (SessionRecord, error)
- func (c *RegistryClient) Session(ctx context.Context, input SessionQueryInput) (SessionRecord, error)
- func (c *RegistryClient) Start(ctx context.Context, input SessionCommandInput) (SessionRecord, error)
- func (c *RegistryClient) Status(ctx context.Context, input SessionQueryInput) (SessionStatus, error)
- func (c *RegistryClient) Stop(ctx context.Context, input SessionCommandInput) (SessionRecord, error)
- type RegistryClientOption
- type SafeError
- type SessionCommandInput
- type SessionKey
- type SessionQueryInput
- type SessionRecord
- type SessionRegistry
- type SessionRegistryContract
- type SessionRegistryRecord
- type SessionSpec
- type SessionStatus
- type TableTheorySessionRegistry
Constants ¶
const ( // ErrorCodeInvalidControllerRequest reports a malformed controller request envelope. ErrorCodeInvalidControllerRequest = "m15.microvm.invalid_controller_request" // ErrorCodeControllerCommandFailed reports a sanitized client command failure. ErrorCodeControllerCommandFailed = "m15.microvm.controller_command_failed" )
const ( // KindLifecycle is the lifecycle contract kind. KindLifecycle ContractKind = "lifecycle" // KindControllerSession is the controller/session contract kind. KindControllerSession ContractKind = "controller_session" // ControllerAuthDefaultDeny is the only controller auth default AppTheory accepts. ControllerAuthDefaultDeny = "deny" // ErrorCodeUnauthenticatedController reports a controller contract or request that does not fail closed. ErrorCodeUnauthenticatedController = "m15.microvm.unauthenticated_controller" // ErrorCodeControllerIncomplete reports an incomplete controller contract. ErrorCodeControllerIncomplete = "m15.microvm.controller_incomplete" // ErrorCodeSessionRegistryIncomplete reports an incomplete session registry contract. ErrorCodeSessionRegistryIncomplete = "m15.microvm.session_registry_incomplete" )
const ( // ErrorCodeInvalidContract reports an unsupported or malformed MicroVM contract. ErrorCodeInvalidContract = "m15.microvm.invalid_contract" // ErrorCodeRawSDKEscapeHatch reports a forbidden raw AWS SDK escape hatch. ErrorCodeRawSDKEscapeHatch = "m15.microvm.raw_sdk_escape_hatch" // ErrorCodeLifecycleBypass reports a forbidden raw lifecycle hook bypass. ErrorCodeLifecycleBypass = "m15.microvm.lifecycle_bypass" //nolint:gosec // Contract error code, not a credential. // ErrorCodeLifecycleIncomplete reports an incomplete lifecycle contract. ErrorCodeLifecycleIncomplete = "m15.microvm.lifecycle_incomplete" // ErrorCodeForbiddenField reports a field that AppTheory refuses to persist or echo. ErrorCodeForbiddenField = "m15.microvm.forbidden_field" // ErrorCodeInvalidLifecycleEvent reports a malformed lifecycle event. ErrorCodeInvalidLifecycleEvent = "m15.microvm.invalid_lifecycle_event" // ErrorCodeLifecycleHookFailed reports a lifecycle hook handler failure. ErrorCodeLifecycleHookFailed = "m15.microvm.lifecycle_hook_failed" )
const ( // ContractName is the only supported AppTheory MicroVM contract name. ContractName = "apptheory.lambda_microvm" // ContractVersion is the M15 MicroVM contract version implemented by this package. ContractVersion = "m15.microvm/v1" )
const ( // EnvSessionRegistryTableName names the TableTheory table used for durable MicroVM session records. EnvSessionRegistryTableName = "APPTHEORY_MICROVM_SESSION_REGISTRY_TABLE" // DefaultSessionRegistryTableName is the default durable MicroVM session registry table name. DefaultSessionRegistryTableName = "apptheory-microvm-sessions" )
Variables ¶
This section is empty.
Functions ¶
func IsTerminalState ¶
func IsTerminalState(state LifecycleState) bool
IsTerminalState reports whether a state is terminal under the M15 contract.
func SessionRegistryPartitionKey ¶
SessionRegistryPartitionKey derives the TableTheory partition key for a tenant-bound namespace.
func SessionRegistrySortKey ¶
SessionRegistrySortKey derives the TableTheory sort key for a session.
func SessionRegistryTableName ¶
func SessionRegistryTableName() string
SessionRegistryTableName returns the configured registry table name.
func ValidateControllerContract ¶
func ValidateControllerContract(contract ControllerContract) error
ValidateControllerContract validates the controller contract vocabulary.
func ValidateEscapeHatches ¶
func ValidateEscapeHatches(escapeHatches EscapeHatches) error
ValidateEscapeHatches fails closed when a contract enables a raw SDK or lifecycle bypass.
func ValidateLifecycleContract ¶
func ValidateLifecycleContract(contract LifecycleContract) error
ValidateLifecycleContract validates the lifecycle contract and returns a safe error on failure.
func ValidateSessionRecord ¶
func ValidateSessionRecord(record SessionRecord) error
ValidateSessionRecord fails closed when a session record is incomplete or contains forbidden metadata.
func ValidateSessionRegistryContract ¶
func ValidateSessionRegistryContract(registry SessionRegistryContract) error
ValidateSessionRegistryContract validates the session registry contract vocabulary.
func ValidateSessionRegistryRecord ¶
func ValidateSessionRegistryRecord(record SessionRegistryRecord) error
ValidateSessionRegistryRecord fails closed when a durable registry item is incomplete, unsafe, or its derived TableTheory keys do not match its tenant/session identity.
func ValidateSessionStatus ¶
func ValidateSessionStatus(status SessionStatus) error
ValidateSessionStatus fails closed when a status response is incomplete.
Types ¶
type AuthContext ¶
type AuthContext struct {
Subject string `json:"subject"`
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace,omitempty"`
Entitlements []string `json:"entitlements,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
AuthContext is the sanitized authenticated principal context required by controller requests.
type Client ¶
type Client interface {
Create(context.Context, CreateSessionInput) (SessionRecord, error)
Start(context.Context, SessionCommandInput) (SessionRecord, error)
Stop(context.Context, SessionCommandInput) (SessionRecord, error)
Status(context.Context, SessionQueryInput) (SessionStatus, error)
Session(context.Context, SessionQueryInput) (SessionRecord, error)
}
Client is the constrained MicroVM client surface. It deliberately exposes no raw AWS SDK client.
type ContractKind ¶
type ContractKind string
ContractKind identifies a MicroVM contract vocabulary kind.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller handles constrained MicroVM control-plane commands.
func NewController ¶
func NewController(client Client, opts ...ControllerOption) (*Controller, error)
NewController creates a fail-closed MicroVM controller.
func (*Controller) Handle ¶
func (c *Controller) Handle(ctx context.Context, request ControllerRequest) (ControllerResponse, error)
Handle executes a controller request after authenticated, tenant-bound envelope validation.
type ControllerAuthContract ¶
type ControllerAuthContract struct {
Required bool `json:"required"`
Default string `json:"default"`
}
ControllerAuthContract describes controller authentication requirements.
type ControllerCommandContract ¶
type ControllerCommandContract struct {
Name Command `json:"name"`
Method string `json:"method"`
Path string `json:"path"`
RequestFields []string `json:"request_fields"`
ResponseFields []string `json:"response_fields"`
}
ControllerCommandContract describes a single controller command.
type ControllerContract ¶
type ControllerContract struct {
Auth ControllerAuthContract `json:"auth"`
Envelope ControllerEnvelopeContract `json:"envelope"`
Commands []ControllerCommandContract `json:"commands"`
}
ControllerContract is the AppTheory MicroVM controller vocabulary.
func DefaultControllerContract ¶
func DefaultControllerContract() ControllerContract
DefaultControllerContract returns the M15 controller command and envelope vocabulary.
type ControllerEnvelopeContract ¶
type ControllerEnvelopeContract struct {
RequiredFields []string `json:"required_fields"`
SafeErrorFields []string `json:"safe_error_fields"`
ForbiddenFields []string `json:"forbidden_fields"`
}
ControllerEnvelopeContract describes the safe controller envelope vocabulary.
type ControllerOption ¶
type ControllerOption func(*Controller)
ControllerOption configures a Controller.
func WithControllerClock ¶
func WithControllerClock(clock Clock) ControllerOption
WithControllerClock sets the controller clock. Nil restores the real clock.
func WithControllerID ¶
func WithControllerID(controllerID string) ControllerOption
WithControllerID sets the controller_id written into session records.
func WithControllerIDGenerator ¶
func WithControllerIDGenerator(ids IDGenerator) ControllerOption
WithControllerIDGenerator sets the controller session ID generator. Nil restores the default generator.
type ControllerRequest ¶
type ControllerRequest struct {
Command Command `json:"command"`
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
AuthContext AuthContext `json:"auth_context"`
SessionID string `json:"session_id,omitempty"`
ImageRef string `json:"image_ref,omitempty"`
NetworkConnectorRef string `json:"network_connector_ref,omitempty"`
SessionSpec SessionSpec `json:"session_spec,omitempty"`
}
ControllerRequest is the single AppTheory MicroVM control-plane request envelope.
type ControllerResponse ¶
type ControllerResponse struct {
Command Command `json:"command"`
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id,omitempty"`
Namespace string `json:"namespace,omitempty"`
SessionID string `json:"session_id,omitempty"`
State LifecycleState `json:"state,omitempty"`
DesiredState LifecycleState `json:"desired_state,omitempty"`
LifecycleState LifecycleState `json:"lifecycle_state,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
MicroVMID string `json:"microvm_id,omitempty"`
LastAction Command `json:"last_action,omitempty"`
LastTransition time.Time `json:"last_transition,omitempty"`
RegistryVersion int64 `json:"registry_version,omitempty"`
Error *SafeError `json:"error,omitempty"`
}
ControllerResponse is the safe controller response envelope.
type CreateSessionInput ¶
type CreateSessionInput struct {
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
ImageRef string `json:"image_ref"`
NetworkConnectorRef string `json:"network_connector_ref"`
SessionSpec SessionSpec `json:"session_spec"`
ControllerID string `json:"controller_id"`
AuthSubject string `json:"auth_subject"`
Now time.Time `json:"now"`
}
CreateSessionInput is the safe client input for creating a session.
type EscapeHatches ¶
type EscapeHatches struct {
RawAWSSDK bool `json:"raw_aws_sdk"`
RawLifecycleHookBypass bool `json:"raw_lifecycle_hook_bypass"`
}
EscapeHatches captures forbidden extension points that must remain disabled.
type IDGenerator ¶
type IDGenerator interface {
NewID() string
}
IDGenerator supplies controller-created session identifiers.
type LifecycleAdapter ¶
type LifecycleAdapter struct {
// contains filtered or unexported fields
}
LifecycleAdapter executes MicroVM lifecycle hooks through the contract vocabulary.
func NewLifecycleAdapter ¶
func NewLifecycleAdapter(opts ...LifecycleOption) (*LifecycleAdapter, error)
NewLifecycleAdapter creates a lifecycle adapter that fails closed when its contract is incomplete.
func (*LifecycleAdapter) Handle ¶
func (a *LifecycleAdapter) Handle(ctx context.Context, event LifecycleEvent) (LifecycleResult, error)
Handle executes one lifecycle hook. Handler errors are sanitized and translated to failed state.
type LifecycleContract ¶
type LifecycleContract struct {
Hooks []LifecycleHookSpec `json:"hooks"`
States []LifecycleState `json:"states"`
TerminalStates []LifecycleState `json:"terminal_states"`
Transitions []LifecycleTransition `json:"transitions"`
}
LifecycleContract is the AppTheory MicroVM lifecycle vocabulary.
func DefaultLifecycleContract ¶
func DefaultLifecycleContract() LifecycleContract
DefaultLifecycleContract returns the M15 MicroVM lifecycle contract vocabulary.
type LifecycleEvent ¶
type LifecycleEvent struct {
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
Hook LifecycleHook `json:"hook"`
State LifecycleState `json:"state"`
Metadata map[string]string `json:"metadata,omitempty"`
}
LifecycleEvent is the sanitized event passed to lifecycle hook handlers. It intentionally contains no raw Lambda payload and no raw AWS SDK client.
type LifecycleHandler ¶
type LifecycleHandler func(context.Context, LifecycleEvent) error
LifecycleHandler handles one sanitized lifecycle hook invocation.
type LifecycleHook ¶
type LifecycleHook string
LifecycleHook names a first-class MicroVM lifecycle hook.
const ( HookPrepareImage LifecycleHook = "prepare_image" HookStart LifecycleHook = "start" HookReadiness LifecycleHook = "readiness" HookStop LifecycleHook = "stop" HookTeardown LifecycleHook = "teardown" HookFailure LifecycleHook = "failure" )
type LifecycleHookSpec ¶
type LifecycleHookSpec struct {
Name LifecycleHook `json:"name"`
Phase string `json:"phase"`
State LifecycleState `json:"state"`
SuccessState LifecycleState `json:"success_state"`
FailureState LifecycleState `json:"failure_state"`
}
LifecycleHookSpec is the contract vocabulary for one lifecycle hook.
type LifecycleOption ¶
type LifecycleOption func(*LifecycleAdapter)
LifecycleOption configures a LifecycleAdapter.
func WithLifecycleContract ¶
func WithLifecycleContract(contract LifecycleContract) LifecycleOption
WithLifecycleContract replaces the default M15 lifecycle contract.
func WithLifecycleHandler ¶
func WithLifecycleHandler(hook LifecycleHook, handler LifecycleHandler) LifecycleOption
WithLifecycleHandler registers a handler for a contract lifecycle hook.
type LifecycleResult ¶
type LifecycleResult struct {
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
Hook LifecycleHook `json:"hook"`
PreviousState LifecycleState `json:"previous_state"`
State LifecycleState `json:"state"`
Metadata map[string]string `json:"metadata,omitempty"`
Error *SafeError `json:"error,omitempty"`
}
LifecycleResult is the safe result returned by a lifecycle adapter.
type LifecycleState ¶
type LifecycleState string
LifecycleState names a contract-defined MicroVM lifecycle state.
const ( StateRequested LifecycleState = "requested" StateImagePreparing LifecycleState = "image_preparing" StateImagePrepared LifecycleState = "image_prepared" StateStarting LifecycleState = "starting" StateStarted LifecycleState = "started" StateReadinessProbing LifecycleState = "readiness_probing" StateReady LifecycleState = "ready" StateStopping LifecycleState = "stopping" StateStopped LifecycleState = "stopped" StateTearingDown LifecycleState = "tearing_down" StateTerminated LifecycleState = "terminated" StateFailed LifecycleState = "failed" )
type LifecycleTransition ¶
type LifecycleTransition struct {
From LifecycleState `json:"from"`
Hook LifecycleHook `json:"hook"`
To LifecycleState `json:"to"`
}
LifecycleTransition is one allowed contract transition.
type MemorySessionRegistry ¶
type MemorySessionRegistry struct {
// contains filtered or unexported fields
}
MemorySessionRegistry is a deterministic in-memory SessionRegistry for tests and local contract runners.
func NewMemorySessionRegistry ¶
func NewMemorySessionRegistry() *MemorySessionRegistry
NewMemorySessionRegistry creates an empty deterministic session registry.
func (*MemorySessionRegistry) Delete ¶
func (r *MemorySessionRegistry) Delete(_ context.Context, key SessionKey) error
Delete removes a record from memory by its tenant-bound key.
func (*MemorySessionRegistry) Get ¶
func (r *MemorySessionRegistry) Get(_ context.Context, key SessionKey) (SessionRecord, error)
Get loads a record from memory by its tenant-bound key.
func (*MemorySessionRegistry) Put ¶
func (r *MemorySessionRegistry) Put(_ context.Context, record SessionRecord) (SessionRecord, error)
Put validates and stores a record in memory.
type RegistryClient ¶
type RegistryClient struct {
// contains filtered or unexported fields
}
RegistryClient is a deterministic constrained MicroVM client backed by a durable SessionRegistry.
func NewRegistryClient ¶
func NewRegistryClient(registry SessionRegistry, opts ...RegistryClientOption) (*RegistryClient, error)
NewRegistryClient creates a constrained client that persists sessions through a SessionRegistry.
func (*RegistryClient) Create ¶
func (c *RegistryClient) Create(ctx context.Context, input CreateSessionInput) (SessionRecord, error)
Create stores a requested durable session record.
func (*RegistryClient) Session ¶
func (c *RegistryClient) Session(ctx context.Context, input SessionQueryInput) (SessionRecord, error)
Session returns the durable session record.
func (*RegistryClient) Start ¶
func (c *RegistryClient) Start(ctx context.Context, input SessionCommandInput) (SessionRecord, error)
Start marks a durable session as starting toward started.
func (*RegistryClient) Status ¶
func (c *RegistryClient) Status(ctx context.Context, input SessionQueryInput) (SessionStatus, error)
Status returns durable status for a session.
func (*RegistryClient) Stop ¶
func (c *RegistryClient) Stop(ctx context.Context, input SessionCommandInput) (SessionRecord, error)
Stop marks a durable session as stopping toward stopped.
type RegistryClientOption ¶
type RegistryClientOption func(*RegistryClient)
RegistryClientOption configures a registry-backed constrained client.
func WithRegistryClientTTL ¶
func WithRegistryClientTTL(ttl time.Duration) RegistryClientOption
WithRegistryClientTTL configures the TTL applied to newly-created durable sessions.
type SafeError ¶
type SafeError struct {
Code string `json:"code"`
Message string `json:"message"`
RequestID string `json:"request_id,omitempty"`
}
SafeError is the MicroVM-safe error envelope exposed by lifecycle and controller adapters. It carries only code, message, and request_id so callers cannot leak raw provider errors, bearer tokens, AWS credentials, or lifecycle payloads through AppTheory primitives.
type SessionCommandInput ¶
type SessionCommandInput struct {
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
ControllerID string `json:"controller_id"`
AuthSubject string `json:"auth_subject"`
DesiredState LifecycleState `json:"desired_state"`
Now time.Time `json:"now"`
}
SessionCommandInput is the safe client input for start/stop commands.
type SessionKey ¶
type SessionKey struct {
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
}
SessionKey identifies a MicroVM session by tenant, namespace, and session_id.
type SessionQueryInput ¶
type SessionQueryInput struct {
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
AuthSubject string `json:"auth_subject"`
}
SessionQueryInput is the safe client input for status/session queries.
type SessionRecord ¶
type SessionRecord struct {
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
State LifecycleState `json:"state"`
DesiredState LifecycleState `json:"desired_state"`
Endpoint string `json:"endpoint,omitempty"`
MicroVMID string `json:"microvm_id,omitempty"`
ImageRef string `json:"image_ref"`
NetworkConnectorRef string `json:"network_connector_ref"`
ControllerID string `json:"controller_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExpiresAt time.Time `json:"expires_at"`
Generation int64 `json:"generation"`
LastAction Command `json:"last_action"`
LastCommandID string `json:"last_command_id"`
AuthSubject string `json:"auth_subject"`
Metadata map[string]string `json:"metadata,omitempty"`
}
SessionRecord is the safe durable-session shape AppTheory exposes to clients and registries.
func SessionRecordFromRegistryRecord ¶
func SessionRecordFromRegistryRecord(record SessionRegistryRecord) (SessionRecord, error)
SessionRecordFromRegistryRecord converts a durable registry item into the safe session record shape.
func (SessionRecord) Key ¶
func (r SessionRecord) Key() SessionKey
Key returns the tenant/namespace/session key for a session record.
type SessionRegistry ¶
type SessionRegistry interface {
Put(context.Context, SessionRecord) (SessionRecord, error)
Get(context.Context, SessionKey) (SessionRecord, error)
Delete(context.Context, SessionKey) error
}
SessionRegistry stores canonical durable MicroVM session records.
type SessionRegistryContract ¶
type SessionRegistryContract struct {
Pattern string `json:"pattern"`
TenantBinding []string `json:"tenant_binding"`
RequiredFields []string `json:"required_fields"`
StateValues []string `json:"state_values"`
ForbiddenFields []string `json:"forbidden_fields"`
}
SessionRegistryContract is the TableTheory-patterned session record vocabulary.
func DefaultSessionRegistryContract ¶
func DefaultSessionRegistryContract() SessionRegistryContract
DefaultSessionRegistryContract returns the M15 session registry vocabulary.
type SessionRegistryRecord ¶
type SessionRegistryRecord struct {
PK string `theorydb:"pk,attr:pk" json:"pk"`
SK string `theorydb:"sk,attr:sk" json:"sk"`
TenantID string `theorydb:"attr:tenant_id" json:"tenant_id"`
Namespace string `theorydb:"attr:namespace" json:"namespace"`
SessionID string `theorydb:"attr:session_id" json:"session_id"`
State LifecycleState `theorydb:"attr:state" json:"state"`
DesiredState LifecycleState `theorydb:"attr:desired_state" json:"desired_state"`
Endpoint string `theorydb:"attr:endpoint,omitempty" json:"endpoint,omitempty"`
MicroVMID string `theorydb:"attr:microvm_id,omitempty" json:"microvm_id,omitempty"`
ImageRef string `theorydb:"attr:image_ref" json:"image_ref"`
NetworkConnectorRef string `theorydb:"attr:network_connector_ref" json:"network_connector_ref"`
ControllerID string `theorydb:"attr:controller_id" json:"controller_id"`
CreatedAt time.Time `theorydb:"attr:created_at" json:"created_at"`
UpdatedAt time.Time `theorydb:"attr:updated_at" json:"updated_at"`
ExpiresAt time.Time `theorydb:"attr:expires_at" json:"expires_at"`
TTL int64 `theorydb:"ttl,attr:ttl" json:"ttl"`
Generation int64 `theorydb:"attr:generation" json:"generation"`
Version int64 `theorydb:"version,attr:version" json:"version"`
LastAction Command `theorydb:"attr:last_action" json:"last_action"`
LastCommandID string `theorydb:"attr:last_command_id" json:"last_command_id"`
AuthSubject string `theorydb:"attr:auth_subject" json:"auth_subject"`
Metadata map[string]string `theorydb:"attr:metadata,omitempty" json:"metadata,omitempty"`
}
SessionRegistryRecord is the canonical TableTheory/DynamoDB-shaped durable MicroVM session item.
PK and SK are derived from tenant_id/namespace/session_id. ValidateSessionRegistryRecord fails closed if those keys do not match the bound tenant/session identity or if metadata contains forbidden fields.
func SessionRecordToRegistryRecord ¶
func SessionRecordToRegistryRecord(record SessionRecord) (SessionRegistryRecord, error)
SessionRecordToRegistryRecord converts a safe session record into the canonical durable registry item.
func (SessionRegistryRecord) TableName ¶
func (SessionRegistryRecord) TableName() string
TableName returns the configured durable MicroVM session registry table name.
type SessionSpec ¶
SessionSpec is the safe session specification accepted by the controller.
type SessionStatus ¶
type SessionStatus struct {
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
SessionID string `json:"session_id"`
State LifecycleState `json:"state"`
DesiredState LifecycleState `json:"desired_state"`
LifecycleState LifecycleState `json:"lifecycle_state"`
Endpoint string `json:"endpoint,omitempty"`
MicroVMID string `json:"microvm_id,omitempty"`
LastAction Command `json:"last_action"`
LastTransition time.Time `json:"last_transition"`
RegistryVersion int64 `json:"registry_version"`
}
SessionStatus is the safe controller status response from a constrained client.
func (SessionStatus) Key ¶
func (s SessionStatus) Key() SessionKey
Key returns the tenant/namespace/session key for a status record.
type TableTheorySessionRegistry ¶
type TableTheorySessionRegistry struct {
// contains filtered or unexported fields
}
TableTheorySessionRegistry stores MicroVM session registry records through the blessed TableTheory DB path.
func NewTableTheorySessionRegistry ¶
func NewTableTheorySessionRegistry(db tablecore.DB) (*TableTheorySessionRegistry, error)
NewTableTheorySessionRegistry creates a TableTheory-backed durable MicroVM session registry.
func (*TableTheorySessionRegistry) Delete ¶
func (r *TableTheorySessionRegistry) Delete(ctx context.Context, key SessionKey) error
Delete removes a tenant-bound session record through TableTheory.
func (*TableTheorySessionRegistry) Get ¶
func (r *TableTheorySessionRegistry) Get(ctx context.Context, key SessionKey) (SessionRecord, error)
Get retrieves a tenant-bound session record through TableTheory.
func (*TableTheorySessionRegistry) Put ¶
func (r *TableTheorySessionRegistry) Put(ctx context.Context, record SessionRecord) (SessionRecord, error)
Put validates and upserts a session record through TableTheory.