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.
type ClientParams ¶
type ClientParams struct { Tracer trace.Tracer Environment env.Environment MaxConnections int DatabaseURI string }
ClientParams encapsulates all Client's dependencies.
Click to show internal directories.
Click to hide internal directories.