util

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 17 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 DBQueryJSON added in v0.7.0

func DBQueryJSON(ctx context.Context, db hub.DB, query string, args ...interface{}) ([]byte, error)

DBQueryJSON is a helper that executes the query provided and returns a bytes slice containing the json data returned from the database.

func DBQueryUnmarshal added in v0.7.0

func DBQueryUnmarshal(ctx context.Context, db hub.DB, v interface{}, query string, args ...interface{}) error

DBQueryUnmarshal is a helper that executes the query provided and unmarshals the json data returned from the database into the value (v) provided.

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,
	hc img.HTTPClient,
	githubRL *rate.Limiter,
) (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