postgres

package
v0.0.0-...-ac3ec41 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package postgres provide access to database with connections and configuration

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	User          string        `yaml:"user" env:"PG_USER"`
	Password      string        `yaml:"password" env:"PG_PASSWORD"`
	Host          string        `yaml:"host" env:"PG_HOST"`
	Port          string        `yaml:"port" env:"" envDefault:"5432"`
	DBName        string        `yaml:"db_name" env:"PG_DB_NAME"`
	MaxPoolSize   int           `yaml:"max_pool_size" env:"pg_max_pool_size"`
	ConnAttempts  int           `yaml:"conn_attempts" env:"pg_ConnAttempts "`
	ConnTimeout   time.Duration `yaml:"conn_timeout" env:"pg_ConnTimeout  "`
	ClickhouseURL string        `yaml:"clickhouse_url" env:"CLICKHOUSE_URL"`
}

Config хранит данные для подключения постгреса

func NewConfig

func NewConfig() Config

NewConfig конструтор

func (*Config) URL

func (c *Config) URL() string

URL возвращает конфиг в виде строки

type Postgres

type Postgres struct {
	Builder squirrel.StatementBuilderType
	Pool    *pgxpool.Pool
}

Postgres агрегатор пула коннектов и построителя запросов

func New

func New(config *Config) (*Postgres, error)

New конструтор

func (*Postgres) Close

func (p *Postgres) Close()

Close закрывает соеденение с БД

Jump to

Keyboard shortcuts

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