sbxstore

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCreating = "creating"
	StatusRunning  = "running"
	StatusPausing  = "pausing"
	StatusPaused   = "paused"
	StatusResuming = "resuming"
	StatusDeleting = "deleting"
	StatusOffline  = "offline"
)

Status constants for sandbox lifecycle.

Variables

This section is empty.

Functions

func ValidTransition

func ValidTransition(from, to string) bool

ValidTransition checks whether a status transition is allowed.

Types

type IdleWatcher

type IdleWatcher struct {
	// contains filtered or unexported fields
}

IdleWatcher monitors sandboxes and auto-pauses idle ones.

func NewIdleWatcher

func NewIdleWatcher(database *db.DB, procMgr process.Manager, store *Store, getTimeout func() time.Duration) *IdleWatcher

NewIdleWatcher creates a new idle sandbox watcher. The getTimeout function is called each check cycle to resolve the current idle timeout. If it returns 0, idle checking is skipped (disabled).

func (*IdleWatcher) Start

func (w *IdleWatcher) Start()

Start begins the idle check loop. Call Stop() to terminate.

func (*IdleWatcher) Stop

func (w *IdleWatcher) Stop()

Stop terminates the idle watcher.

type Sandbox

type Sandbox struct {
	ID              string     `json:"id"`
	ShortID         string     `json:"shortId,omitempty"`
	WorkspaceID     string     `json:"workspaceId"`
	Name            string     `json:"name"`
	Type            string     `json:"type"`
	Status          string     `json:"status"`
	SandboxName     string     `json:"sandboxName,omitempty"`
	PodIP           string     `json:"podIp,omitempty"`
	ProxyToken      string     `json:"-"`
	OpencodeToken   string     `json:"-"`
	OpenclawToken   string     `json:"-"`
	TunnelToken     string     `json:"-"`
	CreatedAt       time.Time  `json:"createdAt"`
	LastActivityAt  *time.Time `json:"lastActivityAt,omitempty"`
	PausedAt        *time.Time `json:"pausedAt,omitempty"`
	IsLocal         bool       `json:"isLocal"`
	LastHeartbeatAt *time.Time `json:"lastHeartbeatAt,omitempty"`
	CPUMillicores   int        `json:"cpuMillicores,omitempty"`
	MemoryBytes     int64      `json:"memoryBytes,omitempty"`
}

Sandbox represents a sandbox with its current state.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages sandboxes via PostgreSQL.

func NewStore

func NewStore(database *db.DB) *Store

func (*Store) Create

func (s *Store) Create(id, workspaceID, name, sandboxType, sandboxName, opencodeToken, proxyToken, openclawToken, shortID string, cpuMillicores int, memoryBytes int64) (*Sandbox, error)

Create inserts a new sandbox into the DB with 'creating' status.

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes a sandbox from the DB.

func (*Store) Get

func (s *Store) Get(id string) (*Sandbox, bool)

Get returns a sandbox from DB.

func (*Store) GetByShortID

func (s *Store) GetByShortID(shortID string) (*Sandbox, bool)

GetByShortID returns a sandbox looked up by its short ID.

func (*Store) ListByWorkspace

func (s *Store) ListByWorkspace(workspaceID string) []*Sandbox

ListByWorkspace returns all sandboxes for a workspace from the database.

func (*Store) Resolve

func (s *Store) Resolve(idOrShortID string) (*Sandbox, bool)

Resolve finds a sandbox by either short ID or UUID. UUIDs are 36 chars; short IDs are 16 chars or fewer. We use 20 as the threshold.

func (*Store) UpdateActivity

func (s *Store) UpdateActivity(id string)

UpdateActivity records user activity on a sandbox.

func (*Store) UpdateStatus

func (s *Store) UpdateStatus(id, status string) error

UpdateStatus transitions a sandbox to a new status.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL