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 ¶
func NewStorage ¶
func NewStorage(config *StorageConfig) *Storage
func (*Storage) InitStorage ¶
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
Click to show internal directories.
Click to hide internal directories.