pg

package
v0.0.0-...-15bed1d Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Type                 string `default:"postgres"`    // primary, secondary
	Name                 string `default:"development"` // business, development
	Host                 string `default:"localhost"`
	Port                 int    `default:"5432"`
	Database             string `default:"postgres"` // dev, 业务数据库
	User                 string `default:"postgres"`
	Passwd               string `default:"Postgresql123!"`
	SSLMode              string `default:"disable"`
	MaxIdleConns         int    `default:"100"`
	MaxOpenConns         int    `default:"200"`
	DisableAutomaticPing bool   `default:"false"`
	Log                  DBLog
	DBNamingStrategy     DBNamingStrategy
	Prometheus           struct {
		Enable          bool     `default:"true"`
		DBName          string   `default:"gorm"`
		RefreshInterval uint32   `default:"15"`
		Prefix          string   `default:"gorm_status_"`
		Interval        uint32   `default:"100"`
		VariableNames   []string `default:"Threads_running"`
	}
}

func (*DB) GetURI

func (c *DB) GetURI() string

func (*DB) Init

func (c *DB) Init(ctx context.Context) (*gorm.DB, error)

func (*DB) Opts

func (c *DB) Opts() *gorm.Config

type DBLog

type DBLog struct {
	SlowThreshold        int    `default:"500"`
	ColorFul             bool   `default:"false"`
	IgnoreRecordNotFound bool   `default:"true"`
	LogLevel             string `default:"warn"`
	DryRun               bool   `default:"false"`
}

type DBNamingStrategy

type DBNamingStrategy struct {
	TablePrefix   string `default:"" description:"table prefix"`
	SingularTable bool   `default:"true" description:"是否使用单数表名"`
}

Jump to

Keyboard shortcuts

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