Documentation
¶
Overview ¶
Package sql implements persistent storage using the postgres database.
Index ¶
- Constants
- func Error(err error) error
- func String(s string) pgtype.Text
- func Timestamptz(t time.Time) pgtype.Timestamptz
- func UUID(s uuid.UUID) pgtype.UUID
- type DB
- func (db *DB) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
- func (db *DB) GetLogs(ctx context.Context, runID string, phase otf.PhaseType) ([]byte, error)
- func (db *DB) Tx(ctx context.Context, callback func(otf.DB) error) error
- func (db *DB) WaitAndLock(ctx context.Context, id int64, fn func() error) error
- type Options
Constants ¶
View Source
const TestDatabaseURL = "OTF_TEST_DATABASE_URL"
Variables ¶
This section is empty.
Functions ¶
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
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 NewContainer ¶ added in v0.0.32
func NewContainer() (*DB, *postgres.PostgresContainer, error)
func (*DB) Tx ¶ added in v0.0.12
Tx provides the caller with a callback in which all operations are conducted within a transaction.
func (*DB) WaitAndLock ¶ added in v0.0.12
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.
Click to show internal directories.
Click to hide internal directories.