db

package
v0.0.0-...-9f01b0d Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProvidePG

func ProvidePG() (*sql.DB, error)

ProvidePG returns sql.DB connection pool for Postgres from env vars

  • PG_PORT
  • PG_MAX_CONNS
  • PG_USER
  • PG_PASS
  • PG_NAME
  • PG_HOST
  • PG_SSL_MODE.

Types

type Connection

type Connection struct {
	User     User
	DBName   string
	Host     string
	Port     int
	SSLMode  string
	MaxConns int
}

Connection encodes SQL connection data.

func ConnectionFromEnv

func ConnectionFromEnv(prefix string) (Connection, error)

ConnectionFromEnv returns Connection from env variables

func (*Connection) Connect

func (c *Connection) Connect() (*sql.DB, error)

Connect tries to connect to postgres until it succeeds.

func (*Connection) String

func (c *Connection) String() string

type User

type User struct {
	Name     string
	Password string
}

func UserFromEnv

func UserFromEnv(prefix string) *User

UserFromEnv returns user from <prefix>_NAME and <prefix>_PASS variables

Jump to

Keyboard shortcuts

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