sql

package module
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseConfig

type DatabaseConfig struct {
	Driver          sql_enum.DatabaseDriver `koanf:"driver" default:"postgres"`
	URL             string                  `koanf:"url" env:"DB_URL"`
	MaxOpenConn     int                     `koanf:"max_open_conn" default:"25"`
	MaxIdleConn     int                     `koanf:"max_idle_conn" default:"5"`
	ConnMaxLifetime time.Duration           `koanf:"conn_max_lifetime" default:"5m"`
	ConnMaxIdleTime time.Duration           `koanf:"conn_max_idle_time" default:"1m"`
	Migration       MigrationConfig         `koanf:"migration"`
	EnableAPM       bool                    `koanf:"enable_apm" env:"ENABLE_APM"`
}

DatabaseConfig конфигурация базы данных

func GetDatabaseConfig

func GetDatabaseConfig() *DatabaseConfig

func (*DatabaseConfig) ConfigKey

func (s *DatabaseConfig) ConfigKey() string

func (*DatabaseConfig) Init

func (cfg *DatabaseConfig) Init() *gorm.DB

Init инициализирует базу данных на основе конфигурации cfg

func (*DatabaseConfig) InitMigrate

func (cfg *DatabaseConfig) InitMigrate()

type MigrationConfig

type MigrationConfig struct {
	Path  string `koanf:"filepath" default:"migration/migrations"`
	Needs bool   `koanf:"needs" default:"false"`
}

Jump to

Keyboard shortcuts

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