Documentation
¶
Index ¶
- Constants
- Variables
- func AbortArchive(ctx context.Context, conn *pgx.Conn, archiveID, clientID uuid.UUID) (removed bool, err error)
- func BeginArchive(ctx context.Context, conn *pgx.Conn, input sqlc.InsertBuildingArchiveParams) (record sqlc.Archive, count int64, err error)
- func CompleteArchive(ctx context.Context, conn *pgx.Conn, archive ReadyArchive) error
- func CreateProjectWithClients(ctx context.Context, pool *pgxpool.Pool, input ProjectWithClientsInput) (sqlc.Project, error)
- func CreateUserWithToken(ctx context.Context, pool *pgxpool.Pool, input CreateUserWithTokenInput) (sqlc.User, error)
- func DeleteProjectWithHistory(ctx context.Context, pool *pgxpool.Pool, projectID uuid.UUID, ...) error
- func IsConstraintViolation(err error, code, constraintName string) bool
- func ReplaceLoginToken(ctx context.Context, pool *pgxpool.Pool, input ReplaceLoginTokenInput) error
- func ReplaceUserProjects(ctx context.Context, pool *pgxpool.Pool, userID uuid.UUID, ...) error
- func UpdateProjectWithClients(ctx context.Context, pool *pgxpool.Pool, input ProjectWithClientsInput) (sqlc.Project, error)
- func UpdateUserProfileWithProjects(ctx context.Context, pool *pgxpool.Pool, ...) (sqlc.User, error)
- func WithArchiveClientLock(ctx context.Context, pool *pgxpool.Pool, clientID uuid.UUID, ...) (locked bool, err error)
- func WithArchiveSchedulerLock(ctx context.Context, pool *pgxpool.Pool, fn func(*pgx.Conn) error) (locked bool, err error)
- type CreateUserWithTokenInput
- type LoginTokenInput
- type ProjectWithClientsInput
- type ReadyArchive
- type ReplaceLoginTokenInput
- type StoredArchive
- type UpdateUserProfileWithProjectsInput
Constants ¶
const ( SQLStateRestrictViolation = "23001" SQLStateForeignKeyViolation = "23503" SQLStateUniqueViolation = "23505" )
Variables ¶
var ( // ErrProjectDeleteConfirmationRequired protects projects with retained clients. ErrProjectDeleteConfirmationRequired = errors.New("project deletion requires its exact current name") // ErrProjectArchiveBusy means an archive build holds the client lock. ErrProjectArchiveBusy = errors.New("project archive is in progress") // ErrArchiveStoreMissing means archive rows exist but no store can remove them. ErrArchiveStoreMissing = errors.New("archive storage is not configured") // ErrArchiveStoreMismatch means an archive row belongs to another storage backend. ErrArchiveStoreMismatch = errors.New("archive storage backend does not match") // ErrArchiveContentCleanup means the project row is gone but a ZIP delete failed. ErrArchiveContentCleanup = errors.New("archive content cleanup failed") )
Functions ¶
func AbortArchive ¶
func AbortArchive(ctx context.Context, conn *pgx.Conn, archiveID, clientID uuid.UUID) (removed bool, err error)
AbortArchive releases claimed logs and removes only a building row. A false result (including an already committed ready row) forbids file cleanup.
func BeginArchive ¶
func BeginArchive(ctx context.Context, conn *pgx.Conn, input sqlc.InsertBuildingArchiveParams) (record sqlc.Archive, count int64, err error)
BeginArchive freezes the exact cohort in the same transaction as its row.
func CompleteArchive ¶
func CreateUserWithToken ¶
func DeleteProjectWithHistory ¶
func DeleteProjectWithHistory(ctx context.Context, pool *pgxpool.Pool, projectID uuid.UUID, confirmationName, backend string, cleanup func(context.Context, []StoredArchive) error) error
DeleteProjectWithHistory removes the project, every client, and their logs, archive rows and policies. Archive files are deleted only after that commit, while the per-client archive locks are still held. A busy lock leaves the project unchanged. Projects with clients require their exact current name, checked under the project lock so concurrent edits cannot bypass confirmation.
func IsConstraintViolation ¶
func ReplaceLoginToken ¶
func ReplaceUserProjects ¶
func WithArchiveClientLock ¶
func WithArchiveClientLock(ctx context.Context, pool *pgxpool.Pool, clientID uuid.UUID, fn func(*pgx.Conn) error) (locked bool, err error)
WithArchiveClientLock holds a session lock and a dedicated connection for the entire build, but does not keep a transaction open during file IO. All build transactions must use this connection: losing it also loses ownership.
Types ¶
type LoginTokenInput ¶
type ProjectWithClientsInput ¶
type ReadyArchive ¶
type ReplaceLoginTokenInput ¶
type ReplaceLoginTokenInput struct {
UserID uuid.UUID
PasswordHash string
Token LoginTokenInput
}
type StoredArchive ¶
StoredArchive is a committed archive object that must be removed after the database delete commits. Keys stay internal to the configured backend.