database

package
v0.0.0-...-a4b8a28 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: CC0-1.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Connection      *sql.DB
	QueueConnection *pgx.ConnPool
)

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxOpenConns       int `conf:"BCDA_DB_MAX_OPEN_CONNS" conf_default:"60"`
	MaxIdleConns       int `conf:"BCDA_DB_MAX_IDLE_CONNS" conf_default:"40"`
	ConnMaxLifetimeMin int `conf:"BCDA_DB_CONN_MAX_LIFETIME_MIN" conf_default:"5"`
	ConnMaxIdleTime    int `conf:"BCDA_DB_CONN_MAX_IDLE_TIME" conf_default:"30"`

	DatabaseURL      string `conf:"DATABASE_URL"`
	QueueDatabaseURL string `conf:"QUEUE_DATABASE_URL"`

	HealthCheckSec int `conf:"DB_HEALTH_CHECK_INTERVAL" conf_default:"5"`
}

func LoadConfig

func LoadConfig() (cfg *Config, err error)

Loads database URLs from environment variables.

func LoadConfigFromParameterStore

func LoadConfigFromParameterStore(dbUrlKey string, queueUrlKey string) (cfg *Config, err error)

Loads database URLs from parameter store instead of from environment variables.

type DB

type DB struct {
	*sql.DB
}

DB is a wrapper around *sql.DB to allow us to implement our internal interfaces

func (*DB) ExecContext

func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)

func (*DB) QueryContext

func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (Rows, error)

func (*DB) QueryRowContext

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) Row

type Executable

type Executable interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)
}

type PgxTx

type PgxTx struct {
	*pgx.Tx
}

func (*PgxTx) ExecContext

func (tx *PgxTx) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)

func (*PgxTx) QueryContext

func (tx *PgxTx) QueryContext(ctx context.Context, query string, args ...interface{}) (Rows, error)

func (*PgxTx) QueryRowContext

func (tx *PgxTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) Row

type Queryable

type Queryable interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) Row
}

type Result

type Result interface {
	RowsAffected() (int64, error)
}

Result is an interface around https://golang.org/pkg/database/sql/#Result. It can be implemented by other database libraries (like pgx)

type Row

type Row interface {
	Scan(dest ...interface{}) error
}

Row is an interface around https://golang.org/pkg/database/sql/#Row. It can be implemented by other database libraries (like pgx)

type Rows

type Rows interface {
	Close() error
	Err() error
	Next() bool
	Scan(dest ...interface{}) error
}

Rows is an interface around https://golang.org/pkg/database/sql/#Rows. It can be implemented by other database libraries (like pgx)

type Tx

type Tx struct {
	*sql.Tx
}

Tx is a wrapper around *sql.DB to allow us to implement our internal interfaces

func (*Tx) ExecContext

func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)

func (*Tx) QueryContext

func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (Rows, error)

func (*Tx) QueryRowContext

func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) Row

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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