buildtaskpg

package
v0.0.0-...-ab31c2f Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

func NewDatabase

func NewDatabase(db Querier) *Database

func (*Database) Begin

func (d *Database) Begin(ctx context.Context) (buildtask.DatabaseTx, error)

Begin implements buildtask.Database.

func (*Database) CreateBuild

CreateBuild implements buildtask.Database.

func (*Database) GetBuild

GetBuild implements buildtask.Database.

TODO: Consider silent unmarshalling errors of pgx.CollectExactlyOneRow(rows, rowToBuild) here and in other Database methods.

func (*Database) GetBuildByIdempotencyKey

func (d *Database) GetBuildByIdempotencyKey(ctx context.Context, params *buildtask.DatabaseGetBuildByIdempotencyKeyParams) (*buildtask.Build, error)

GetBuildByIdempotencyKey implements buildtask.Database.

func (*Database) GetBuildCount

func (d *Database) GetBuildCount(ctx context.Context, params *buildtask.DatabaseGetBuildCountParams) (int, error)

GetBuildCount implements buildtask.Database.

TODO: params.StartTime and params.EndTime could be invalid. What should we do about this? Options: a) leave it as it is, then the select query will always return zero; b) return a validation error; c) panic (we consider calling GetBuildCount like that a programming error).

func (*Database) ListBuilds

ListBuilds implements buildtask.Database.

TODO: params.PageLimit and params.PageOffset could be invalid. What should we do about that? Options: a) leave it as it is, then the select query will always return zero; b) return a validation error; c) panic.

func (*Database) LockBuilds

func (d *Database) LockBuilds(ctx context.Context, params *buildtask.DatabaseLockBuildsParams) error

LockBuilds implements buildtask.Database.

INSERT with ON CONFLICT DO UPDATE should acquire the FOR UPDATE row-level lock when the user_id row exists and acquire a lock when it doesn't exist.

TODO: check the INSERT with ON CONFLICT DO UPDATE command.

func (*Database) UpdateBuild

type DatabaseTx

type DatabaseTx struct {
	*Database // required
	// contains filtered or unexported fields
}

func (*DatabaseTx) Commit

func (tx *DatabaseTx) Commit(ctx context.Context) error

func (*DatabaseTx) Rollback

func (tx *DatabaseTx) Rollback(ctx context.Context) error

type Querier

type Querier interface {
	Begin(ctx context.Context) (pgx.Tx, error)
	Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
}

Jump to

Keyboard shortcuts

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