postgres

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCantOpenConnection indicates an error on openning connection to the postgres database.
	ErrCantOpenConnection = errors.New("error on openning connection to the postgres database").WithCode("CANT_OPEN_POSTGRES_CONNECTION")
	// ErrDatabaseNotReached indicates that the database can not be reached.
	ErrDatabaseNotReached = errors.New("the database can not be reached").WithCode("CANT_REACH_POSTGRES_DATABASE")
)

Functions

func Driver added in v0.1.2

func Driver(e env.Environment) string

Driver indicates which Postgres driver should be used based on environment.

Types

type Client

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

Client is a custom postgres client.

func MustNewClient

func MustNewClient(params ClientParams) Client

MustNewClient creates a new Client instance. It uses postgres generic driver by default. If in production environment, uses cloudsqlpostgres driver. It uses 5 max connections by default. It panics if any error is found.

func NewClient

func NewClient(params ClientParams) (Client, error)

NewClient creates a new Client instance. It uses postgres generic driver by default. If in production environment, uses cloudsqlpostgres driver. It uses 5 max connections by default.

func (Client) Connect

func (c Client) Connect(ctx context.Context) (*sql.DB, error)

Connect connects the client with the database.

type ClientParams

type ClientParams struct {
	Tracer         trace.Tracer
	Environment    env.Environment
	MaxConnections int
	DatabaseURI    string
}

ClientParams encapsulates all Client's dependencies.

Jump to

Keyboard shortcuts

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