Documentation
¶
Overview ¶
Package rowlock owns the invariant PostgreSQL lock order for durable resource mutations. Every caller locks quota ledgers before Sandbox, then Workspace, then Snapshot when present, before acquiring operation-specific rows.
Index ¶
- func ActiveSubject(ctx context.Context, tx pgx.Tx, tenantRef string, subjectRef string, ...) error
- func QuotaScopes(ctx context.Context, tx pgx.Tx, scopes []QuotaScope) error
- func SandboxQuota(ctx context.Context, tx pgx.Tx, sandboxID string) error
- func SandboxQuotas(ctx context.Context, tx pgx.Tx, sandboxIDs []string) error
- func TenantAndSubjectQuota(ctx context.Context, tx pgx.Tx, tenantRef string, subjectRef string) error
- func TenantQuota(ctx context.Context, tx pgx.Tx, tenantRef string) error
- type QuotaScope
- type SandboxWorkspace
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveSubject ¶ added in v0.6.0
func ActiveSubject( ctx context.Context, tx pgx.Tx, tenantRef string, subjectRef string, now time.Time, ) error
ActiveSubject locks and validates the Subject after its quota ledger and before quota-bearing domain rows.
func QuotaScopes ¶ added in v0.6.0
QuotaScopes locks all tenant ledgers first, then all Subject ledgers, with each level sorted by logical identity before any domain row is locked.
func SandboxQuota ¶ added in v0.6.0
SandboxQuota locks the quota ledgers for a Sandbox before locking the Sandbox itself.
func SandboxQuotas ¶ added in v0.6.0
SandboxQuotas resolves Sandbox ownership without row locks, then locks every quota-ledger pair before a caller acquires any durable domain-row lock.
func TenantAndSubjectQuota ¶ added in v0.6.0
func TenantAndSubjectQuota( ctx context.Context, tx pgx.Tx, tenantRef string, subjectRef string, ) error
TenantAndSubjectQuota establishes the global PostgreSQL mutation lock order: tenant quota ledger, subject quota ledger, then domain rows such as Subject, ApplicationAuthority, Sandbox, Workspace, Snapshot, PortSession, or data-plane session. Trigger-backed quota accounting depends on every writer preserving this order before it locks or changes a quota-bearing domain row.
Types ¶
type QuotaScope ¶ added in v0.6.0
QuotaScope identifies one tenant and Subject quota-ledger pair.
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.
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.