util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDBInsufficientPrivilege indicates that the user does not have the
	// required privilege to perform the operation.
	ErrDBInsufficientPrivilege = errors.New("ERROR: insufficient_privilege (SQLSTATE 42501)")
)

Functions

func DBTransact

func DBTransact(ctx context.Context, db hub.DB, txFunc func(pgx.Tx) error) (err error)

DBTransact is a helper function that wraps some database transactions taking care of committing and rolling back when needed.

func SetupConfig

func SetupConfig(cmd string) (*viper.Viper, error)

SetupConfig creates a new Viper instance to handle the configuration for a particular cmd. Configuration can be provided in a config file or using env variables. See configs folder for some examples.

func SetupDB

func SetupDB(cfg *viper.Viper) (*pgxpool.Pool, error)

SetupDB creates a database connection pool using the configuration provided.

func SetupImageStore

func SetupImageStore(cfg *viper.Viper, db pg.DB) (img.Store, error)

SetupImageStore creates a new image store based on the configuration provided.

func SetupLogger

func SetupLogger(cfg *viper.Viper, fields map[string]interface{}) error

SetupLogger configures the global logger using the configuration provided.

Types

This section is empty.

Jump to

Keyboard shortcuts

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