database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

Functions

func DSN

func DSN() (string, error)

DSN returns the data soure name from the environment. If there is a configuration problem an error is returned.

func Execute

func Execute(ctx context.Context, fn func(context.Context, *sql.Conn) error) error

func Query

func Query(
	ctx context.Context,
	conn *sql.Conn,
	fn func(*sql.Rows) error,
	query string,
	args ...interface{},
) error

func QueryWithoutCtx

func QueryWithoutCtx(
	fn func(*sql.Rows) error,
	query string,
	arguments ...interface{},
) error

func TransactionExec

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

Types

type Configuration

type Configuration map[string]string

Configuration represents a set of configuration key/value pairs.

func GetConfiguration

func GetConfiguration(name string) (Configuration, error)

GetConfiguration returns a named configuration from the database. If this fails an error is returned. The returned configuration even if fetching was not successful can be used to lookup specific values for given keys.

func LoadConfiguration

func LoadConfiguration(name string) (Configuration, error)

LoadConfiguration loads an uncached configuration from the database.

func LoadConfigurationPrefix

func LoadConfigurationPrefix(name, prefix string) (Configuration, error)

LoadConfiguration loads an uncached configuration from the database where the keys have a given prefix.

func (Configuration) Int64

func (cfg Configuration) Int64(key string, def int64) int64

Int64 returns the int64 value for a given key. If not found the given default value is returned. This methods works on uninitialized configurations, too.

func (Configuration) String

func (cfg Configuration) String(key, def string) string

String returns the string value for a given key. If not found the given default value is returned. This methods works on uninitialized configurations, too.

Jump to

Keyboard shortcuts

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