db

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectOptions

type ConnectOptions struct {
	DSN                string
	DriverName         string
	Retries            int
	RetryDelay         time.Duration
	ConnectTimeout     time.Duration
	ConnMaxLifetime    time.Duration
	MaxIdleConnections int
	MaxOpenConnections int
}

ConnectOptions config options for database

type DB

type DB struct {
	*sql.DB
}

DB type to wrap sql.DB

type DBReaderWriter

type DBReaderWriter struct {
	Reader *DB
	Writer *DB
}

DBReaderWriter wraps db reader and writer

func NewDbConnection

func NewDbConnection(ctx context.Context, ready *bool, ro ConnectOptions, wo ConnectOptions) *DBReaderWriter

NewDbConnection connects to the reader and writer per passed in options, with retries, returning a DBReaderWriter object that contains sql.DB connection

func (*DBReaderWriter) GetReaderConn

func (dbs *DBReaderWriter) GetReaderConn() *sql.DB

GetReaderConn returns connection to reader

func (*DBReaderWriter) GetWriterConn

func (dbs *DBReaderWriter) GetWriterConn() *sql.DB

GetWriterConn returns connection to writer

type DbStore

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

DbStore holds the database connection and other stuff.

func NewDbConnectionForTest

func NewDbConnectionForTest(ctx context.Context, settings config.Settings, withSearchPath bool) DbStore

NewDbConnectionForTest use this for tests as we have multiple sessions in parallel and don't want synced one

func NewDbConnectionFromSettings

func NewDbConnectionFromSettings(ctx context.Context, settings *config.Settings, withSearchPath bool) DbStore

NewDbConnectionFromSettings sets up a db connection from the settings, only once

func (*DbStore) DBS

func (store *DbStore) DBS() *DBReaderWriter

DBS returns the reader and writer databases to connect to

func (*DbStore) IsReady

func (store *DbStore) IsReady() bool

IsReady returns if db is ready to connect to

type Tx

type Tx struct {
	*sql.Tx
}

Tx type to wrap sql.Tx

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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