rowlock

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package rowlock owns the invariant PostgreSQL lock order for local Workspace mutations. Every caller locks Sandbox, then Workspace, then Snapshot when present before acquiring any operation-specific rows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SandboxWorkspace

type SandboxWorkspace struct {
	SandboxID         string
	TenantRef         string
	SubjectRef        string
	WorkspaceID       string
	ProfileRevisionID string
	SandboxState      string
	DesiredState      string
	Generation        int64
	Revision          int64
	CurrentInstanceID string
	ReconcileOwner    string
	Workspace         ports.HomeWorkspace
}

SandboxWorkspace is the durable authority protected by the first two locks.

func SandboxWorkspaceByID

func SandboxWorkspaceByID(
	ctx context.Context,
	tx pgx.Tx,
	sandboxID string,
) (SandboxWorkspace, error)

SandboxWorkspaceByID locks one internally identified Sandbox followed by its Workspace.

func SandboxWorkspaceForSubject

func SandboxWorkspaceForSubject(
	ctx context.Context,
	tx pgx.Tx,
	tenantRef string,
	subjectRef string,
	sandboxID string,
) (SandboxWorkspace, error)

SandboxWorkspaceForSubject locks one tenant-scoped Sandbox followed by its Workspace.

type Snapshot

type Snapshot struct {
	ID           string
	SandboxID    string
	WorkspaceID  string
	HomeRunnerID string
	State        string
}

Snapshot identifies the third row in the invariant lock order.

func SnapshotByID

func SnapshotByID(
	ctx context.Context,
	tx pgx.Tx,
	locked SandboxWorkspace,
	snapshotID string,
) (Snapshot, error)

SnapshotByID locks a Snapshot only after the caller holds its Sandbox and Workspace.

func SnapshotForSubject

func SnapshotForSubject(
	ctx context.Context,
	tx pgx.Tx,
	tenantRef string,
	subjectRef string,
	locked SandboxWorkspace,
	snapshotID string,
) (Snapshot, error)

SnapshotForSubject locks a Snapshot only after the caller holds its Sandbox and Workspace through SandboxWorkspaceForSubject or SandboxWorkspaceByID.

Jump to

Keyboard shortcuts

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