Documentation ¶
Index ¶
- type Database
- func (d *Database) Begin(ctx context.Context) (buildtask.DatabaseTx, error)
- func (d *Database) CreateBuild(ctx context.Context, params *buildtask.DatabaseCreateBuildParams) (*buildtask.Build, error)
- func (d *Database) GetBuild(ctx context.Context, params *buildtask.DatabaseGetBuildParams) (*buildtask.Build, error)
- func (d *Database) GetBuildByIdempotencyKey(ctx context.Context, params *buildtask.DatabaseGetBuildByIdempotencyKeyParams) (*buildtask.Build, error)
- func (d *Database) GetBuildCount(ctx context.Context, params *buildtask.DatabaseGetBuildCountParams) (int, error)
- func (d *Database) ListBuilds(ctx context.Context, params *buildtask.DatabaseListBuildsParams) (*buildtask.DatabaseListBuildsResult, error)
- func (d *Database) LockBuilds(ctx context.Context, params *buildtask.DatabaseLockBuildsParams) error
- func (d *Database) UpdateBuild(ctx context.Context, params *buildtask.DatabaseUpdateBuildParams) (*buildtask.Build, error)
- type DatabaseTx
- type Querier
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 (*Database) CreateBuild ¶
func (d *Database) CreateBuild(ctx context.Context, params *buildtask.DatabaseCreateBuildParams) (*buildtask.Build, error)
CreateBuild implements buildtask.Database.
func (*Database) GetBuild ¶
func (d *Database) GetBuild(ctx context.Context, params *buildtask.DatabaseGetBuildParams) (*buildtask.Build, error)
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 ¶
func (d *Database) ListBuilds(ctx context.Context, params *buildtask.DatabaseListBuildsParams) (*buildtask.DatabaseListBuildsResult, error)
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 }
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 }