store

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("sandbox not found")

Functions

This section is empty.

Types

type Store

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

func Open

func Open(path string) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Create

func (s *Store) Create(ctx context.Context, sandbox *models.Sandbox) error

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

func (*Store) DeleteMounts

func (s *Store) DeleteMounts(ctx context.Context, sandboxID string) error

DeleteMounts removes mount config for a sandbox. The cascade on the sandboxes table handles this when a sandbox is destroyed; explicit deletes are useful for replacing mounts.

func (*Store) DeletePort

func (s *Store) DeletePort(ctx context.Context, sandboxID string, port int) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*models.Sandbox, error)

func (*Store) GetMounts

func (s *Store) GetMounts(ctx context.Context, sandboxID string) ([]byte, error)

GetMounts returns the encrypted mount blob, or ErrNotFound if no row exists.

func (*Store) HasActiveImageRef

func (s *Store) HasActiveImageRef(ctx context.Context, image string) (bool, error)

HasActiveImageRef reports whether any sandbox row references image with a status other than destroyed. Used by image GC: when this returns false the caller may safely remove the image from Docker. Single indexed query — constant cost regardless of how many destroyed rows have accumulated, so 10k destroyed historical rows do not slow the destroy hot path. Returns true on empty image as a conservative default (caller treats it as "still in use, do not delete").

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*models.Sandbox, error)

func (*Store) PurgeDestroyedBefore

func (s *Store) PurgeDestroyedBefore(ctx context.Context, cutoff time.Time) (int64, error)

PurgeDestroyedBefore deletes sandbox rows that are in the destroyed state and whose updated_at is older than cutoff. Returns the number of rows deleted. Only destroyed rows are eligible — live sandboxes are never touched, so this is safe to call concurrently with normal lifecycle operations. Cascades through the foreign key on exposed_ports and sandbox_mounts. Powered by idx_sandboxes_status, so cost scales with the number of destroyed rows being purged, not the total table size.

func (*Store) PutMounts

func (s *Store) PutMounts(ctx context.Context, sandboxID string, sealed []byte) error

PutMounts stores an encrypted mount blob for a sandbox. The blob is opaque to the store layer; encryption / decryption happens in the service layer.

func (*Store) Touch

func (s *Store) Touch(ctx context.Context, id string, at time.Time) error

func (*Store) UpdateLifecycle

func (s *Store) UpdateLifecycle(ctx context.Context, id string, l models.Lifecycle) error

UpdateLifecycle replaces the four lifecycle timer fields on a sandbox row and bumps updated_at. Other fields are untouched. Returns ErrNotFound if no row matches id. The caller must validate the Lifecycle first; the store does not re-validate (it would couple two layers for no gain).

func (*Store) UpdateRuntime

func (s *Store) UpdateRuntime(ctx context.Context, id, containerID, containerIP, publicURL string) error

func (*Store) UpdateStatus

func (s *Store) UpdateStatus(ctx context.Context, id string, status models.SandboxStatus, lastError string) error

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, sandbox *models.Sandbox) error

func (*Store) UpsertPort

func (s *Store) UpsertPort(ctx context.Context, exposure models.ExposedPort) error

Jump to

Keyboard shortcuts

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