pgrepo

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

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

Repository knows how to handle a postgres backend database.

The database driver is instrumented for tracing.

func NewRepository

func NewRepository(app string, zlg *zap.Logger, lg log.Factory, cfg *viper.Viper) *Repository

NewRepository creates a new postgres repository.

The new repository needs to be started wih Start() in order to create the connection pools.

func (Repository) Config

func (r Repository) Config() *viper.Viper

Config returns a configuration registry

func (Repository) ConnConfig

func (r Repository) ConnConfig(u string, zlg *zap.Logger, app string) *pgx.ConnConfig

func (*Repository) DB

func (r *Repository) DB() *sqlx.DB

DB master instance

func (Repository) DBURL

func (r Repository) DBURL() string

func (*Repository) HealthCheck

func (r *Repository) HealthCheck() error

HealthCheck pings the database

func (Repository) LogLevel

func (r Repository) LogLevel() tracelog.LogLevel

LogLevel returns a pgx log level from config

func (Repository) Logger

func (r Repository) Logger() log.Factory

Logger returns a logger factory

func (*Repository) Sample

func (r *Repository) Sample() repos.SampleRepo

func (Repository) SetPool

func (r Repository) SetPool(db *sql.DB)

SetPool sets the connection pool parameters from config

func (*Repository) Start

func (r *Repository) Start() error

Start a connection pool to a database, plus possibly another one to the read-only version of it

func (*Repository) Stop

func (r *Repository) Stop() error

Stop the repository and close all connection pools.

Stop may be called safely even if the database connection failed to start properly.

func (Repository) TraceOptions

func (r Repository) TraceOptions(u string) []ocsql.TraceOption

TraceOptions returns the trace options for the opencensus driver wrapper

func (Repository) Validate

func (r Repository) Validate() error

Validate the configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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