db

package
v0.0.0-...-58e3b6f Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost                        = "localhost"
	DefaultPort                        = 5432
	DefaultConnectAttempts             = 10
	DefaultConnectDelay                = 10 // seconds
	DefaultConnectMaxOpens             = 10
	DefaultBackgroundCheckConnectDelay = 10 // seconds

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

type Storage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage(config *StorageConfig) *Storage

func (*Storage) Close

func (s *Storage) Close()

func (*Storage) Get

func (s *Storage) Get(ctx context.Context, dest any, query string, params ...any) error

func (*Storage) InitStorage

func (s *Storage) InitStorage() error

func (*Storage) Insert

func (s *Storage) Insert()

func (*Storage) Ping

func (s *Storage) Ping() error

type StorageConfig

type StorageConfig struct {
	Host                        string // localhost
	Port                        uint16 // 5432
	Username                    string
	Password                    string
	Database                    string
	ConnectAttempts             int8   // максимальное количество попыток подключения (по-умолчанию 10)
	ConnectDelay                uint64 // задержка перед повторным подключением в секундах (по-умолчанию 10)
	ConnectMaxOpens             int    // максимальное количество открытых соединений (по-умолчанию 10)
	BackgroundCheckConnectDelay uint64 // по-умолчанию 10
}

func NewStorageConfig

func NewStorageConfig() *StorageConfig

func (*StorageConfig) GetDSN

func (config *StorageConfig) GetDSN() string

type StorageConnection

type StorageConnection struct {
	DB     *sqlx.DB
	Config *StorageConfig
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(config *StorageConfig) *StorageConnection

func (*StorageConnection) BackgroundCheckConnect

func (conn *StorageConnection) BackgroundCheckConnect()

BackgroundCheckConnect метод, который через указанное в конфиге время проверяет подключение к PostgreSQL

func (*StorageConnection) Close

func (conn *StorageConnection) Close()

func (*StorageConnection) Open

func (conn *StorageConnection) Open() error

func (*StorageConnection) Ping

func (conn *StorageConnection) Ping() error

Jump to

Keyboard shortcuts

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