Documentation
¶
Index ¶
- Variables
- type ReserveHostPortResult
- type Store
- func (s *Store) Close() error
- func (s *Store) Create(ctx context.Context, sandbox *models.Sandbox) error
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) DeleteMounts(ctx context.Context, sandboxID string) error
- func (s *Store) DeletePort(ctx context.Context, sandboxID string, port int) error
- func (s *Store) Get(ctx context.Context, id string) (*models.Sandbox, error)
- func (s *Store) GetMounts(ctx context.Context, sandboxID string) ([]byte, error)
- func (s *Store) HasActiveImageRef(ctx context.Context, image string) (bool, error)
- func (s *Store) List(ctx context.Context) ([]*models.Sandbox, error)
- func (s *Store) ListAllExposedPorts(ctx context.Context) ([]models.ExposedPort, error)
- func (s *Store) PutMounts(ctx context.Context, sandboxID string, sealed []byte) error
- func (s *Store) Touch(ctx context.Context, id string, at time.Time) error
- func (s *Store) TryReserveHostPort(ctx context.Context, sandboxID string, containerPort, hostPort int, ...) (ReserveHostPortResult, error)
- func (s *Store) UpdateLifecycle(ctx context.Context, id string, l models.Lifecycle) error
- func (s *Store) UpdateRuntime(ctx context.Context, id, containerID, containerIP, publicURL string) error
- func (s *Store) UpdateStatus(ctx context.Context, id string, status models.SandboxStatus, lastError string) error
- func (s *Store) Upsert(ctx context.Context, sandbox *models.Sandbox) error
- func (s *Store) UpsertPort(ctx context.Context, exposure models.ExposedPort) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("sandbox not found")
Functions ¶
This section is empty.
Types ¶
type ReserveHostPortResult ¶ added in v0.1.4
type ReserveHostPortResult struct {
Reserved bool
Existing *models.ExposedPort
}
ReserveHostPortResult is the three-state outcome of TryReserveHostPort. Exactly one of Reserved/Existing/(neither) is set:
- Reserved: the row was inserted; the candidate host port is now ours.
- Existing != nil: a row for (sandbox_id, port) already exists. The allocator MUST stop walking the pool — no other host_port will satisfy the (sandbox_id, port) primary key. Caller decides whether to reuse the existing exposure or surface an error.
- both zero: the partial unique index on host_port rejected this candidate (some other sandbox owns it). Caller may retry.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) DeleteMounts ¶
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 (*Store) GetMounts ¶
GetMounts returns the encrypted mount blob, or ErrNotFound if no row exists.
func (*Store) HasActiveImageRef ¶
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) ListAllExposedPorts ¶ added in v0.1.4
ListAllExposedPorts returns every row in exposed_ports across every sandbox. Used by reconcile to GC zombie caddy routes / layer4 servers without N+1 per-sandbox lookups.
func (*Store) PutMounts ¶
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) TryReserveHostPort ¶ added in v0.1.4
func (s *Store) TryReserveHostPort(ctx context.Context, sandboxID string, containerPort, hostPort int, protocol, publicURL string, now time.Time) (ReserveHostPortResult, error)
TryReserveHostPort attempts to claim hostPort for (sandboxID, containerPort) in a single INSERT OR IGNORE. The OR IGNORE swallows two distinct UNIQUE failures — the (sandbox_id, port) primary key AND the partial index on host_port — so on a no-op insert we follow up with a SELECT to disambiguate. Without that disambiguation, retrying expose for an already-exposed port looks identical to a host_port collision and walks the whole allocator pool before failing with "exhausted".
func (*Store) UpdateLifecycle ¶
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).