sql

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package sql implements persistent storage using the postgres database.

Index

Constants

View Source
const TestDatabaseURL = "OTF_TEST_DATABASE_URL"

Variables

This section is empty.

Functions

func Error added in v0.0.23

func Error(err error) error

func String added in v0.0.12

func String(s string) pgtype.Text

String converts a go-string into a postgres non-null string

func Timestamptz added in v0.0.12

func Timestamptz(t time.Time) pgtype.Timestamptz

Timestamptz converts a go-time into a postgres non-null timestamptz

func UUID added in v0.0.19

func UUID(s uuid.UUID) pgtype.UUID

UUID converts a google-go-uuid into a postgres non-null UUID

Types

type DB added in v0.0.12

type DB struct {
	*pgxpool.Pool // db connection pool
	pggen.Querier // generated queries
	// contains filtered or unexported fields
}

DB provides access to the postgres db as well as queries generated from SQL

func New

func New(ctx context.Context, opts Options) (*DB, error)

New constructs a new DB connection pool, and migrates the schema to the latest version.

func NewContainer added in v0.0.32

func NewContainer() (*DB, *postgres.PostgresContainer, error)

func NewTestDB added in v0.0.23

func NewTestDB(t *testing.T) (*DB, string)

func (*DB) Exec added in v0.0.32

func (db *DB) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

func (*DB) GetLogs added in v0.0.32

func (db *DB) GetLogs(ctx context.Context, runID string, phase otf.PhaseType) ([]byte, error)

GetLogs retrieves the logs for a given run phase.

func (*DB) Tx added in v0.0.12

func (db *DB) Tx(ctx context.Context, callback func(otf.DB) error) error

Tx provides the caller with a callback in which all operations are conducted within a transaction.

func (*DB) WaitAndLock added in v0.0.12

func (db *DB) WaitAndLock(ctx context.Context, id int64, fn func() error) error

WaitAndLock obtains an exclusive session-level advisory lock. If another session holds the lock with the given id then it'll wait until the other session releases the lock. The given fn is called once the lock is obtained and when the fn finishes the lock is released.

type Options added in v0.0.19

type Options struct {
	Logger     logr.Logger
	ConnString string
}

Options for constructing a DB

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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