db

package
v0.0.0-...-415d676 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

PostgresDBProviderSet is a provider set for building a Postgres database

View Source
var ProvidePostgresCounterDAO = wire.NewSet(
	wire.Struct(new(PostgresCounterDAO), "DB", "Log"),
	wire.Bind(new(CounterDAO), new(*PostgresCounterDAO)),
)

ProvidePostgresCounterDAO is a provider set for building a PostgresCounterDAO

Functions

This section is empty.

Types

type CounterDAO

type CounterDAO interface {
	Value(ctx context.Context) (int, error)
	Increment(ctx context.Context) (int, error)
}

CounterDAO is a generic interface for a DAO accessing a counter

type PostgresCounterDAO

type PostgresCounterDAO struct {
	DB  PostgresDBConn
	Log *log.MultiLogger
}

PostgresCounterDAO implements a CounterDAO for a Postgres database

func (PostgresCounterDAO) Increment

func (dao PostgresCounterDAO) Increment(ctx context.Context) (int, error)

Increment increases the counter and returns its new value

func (PostgresCounterDAO) Value

func (dao PostgresCounterDAO) Value(ctx context.Context) (int, error)

Value retrieves the value of the counter

type PostgresDBConn

type PostgresDBConn *sql.DB

PostgresDBConn is a database connection to a Postgres DB

func ProvidePostgresDBConn

func ProvidePostgresDBConn(logger *log.MultiLogger, db PreInitPostgresDBConn) (PostgresDBConn, error)

ProvidePostgresDBConn performs schema initialization

type PreInitPostgresDBConn

type PreInitPostgresDBConn *sql.DB

PreInitPostgresDBConn is a database connection to a Postgres DB which may not have initialized schema

func ProvidePreInitPostgresDBConn

func ProvidePreInitPostgresDBConn(logger *log.MultiLogger, dbString config.DatabaseString) (PreInitPostgresDBConn, func(), error)

ProvidePreInitPostgresDBConn provides a PostgresDBConn by connecting to a database

Jump to

Keyboard shortcuts

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