config

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Port               string           `yaml:"port"`
	Fast               any              `yaml:"fast"`
	Methods            string           `yaml:"methods"`
	FastGroup          string           `yaml:"fastGroup"`
	ServerName         string           `yaml:"serverName"`
	Routes             []RouteConfig    `yaml:"routes"`
	Datasource         DatasourceConfig `yaml:"datasource"`
	DisableSnowflakeId bool             `yaml:"disableSnowflakeId"`
}
var (
	Config *AppConfig
)

func (*AppConfig) Load

func (conf *AppConfig) Load() (*AppConfig, error)

type DBConfig

type DBConfig struct {
	ConnectString string `yaml:"connectString"`
	Driver        string `yaml:"driver"`
}

type DatasourceConfig

type DatasourceConfig struct {
	Config      GOrmConfig          `yaml:"Config"`
	Pools       PoolsConfig         `yaml:"pools"`
	Connections map[string]DBConfig `yaml:"connections"`
	Prometheus  prometheus.Config   `yaml:"prometheus"`
}

type GOrmConfig

type GOrmConfig struct {
	// GORM perform single create, update, delete operations in transactions by default to ensure database data integrity
	// You can disable it by setting `SkipDefaultTransaction` to true
	SkipDefaultTransaction bool `yaml:"skipDefaultTransaction"`
	// NamingStrategy tables, columns naming strategy
	NamingStrategy schema.Namer `yaml:"namingStrategy"`
	// FullSaveAssociations full save associations
	FullSaveAssociations bool `yaml:"fullSaveAssociations,omitempty"`
	// Logger
	Logger logger.Interface `yaml:"logger,omitempty"`
	// NowFunc the function to be used when creating a new timestamp
	NowFunc func() time.Time `yaml:"nowFunc"`
	// DryRun generate sql without execute
	DryRun bool `yaml:"dryRun"`
	// PrepareStmt executes the given query in cached statement
	PrepareStmt bool `yaml:"prepareStmt"`
	// DisableAutomaticPing
	DisableAutomaticPing bool `yaml:"disableAutomaticPing"`
	// DisableForeignKeyConstraintWhenMigrating
	DisableForeignKeyConstraintWhenMigrating bool `yaml:"disableForeignKeyConstraintWhenMigrating"`
	// IgnoreRelationshipsWhenMigrating
	IgnoreRelationshipsWhenMigrating bool `yaml:"ignoreRelationshipsWhenMigrating"`
	// DisableNestedTransaction disable nested transaction
	DisableNestedTransaction bool `yaml:"disableNestedTransaction"`
	// AllowGlobalUpdate allow global update
	AllowGlobalUpdate bool `yaml:"allowGlobalUpdate"`
	// QueryFields executes the SQL query with all fields of the table
	QueryFields bool `yaml:"queryFields"`
	// CreateBatchSize default create batch size
	CreateBatchSize int `yaml:"createBatchSize"`
	// TranslateError enabling error translation
	TranslateError bool `yaml:"translateError"`
	// PropagateUnscoped propagate Unscoped to every other nested statement
	PropagateUnscoped bool `yaml:"propagateUnscoped"`

	// ClauseBuilders clause builder
	ClauseBuilders map[string]clause.ClauseBuilder `yaml:"clauseBuilders"`
	CacheStore     *sync.Map                       `yaml:"cacheStore"`
}

Config GORM Config

func (GOrmConfig) AfterInitialize

func (G GOrmConfig) AfterInitialize(db *gorm.DB) error

func (GOrmConfig) Apply

func (G GOrmConfig) Apply(c *gorm.Config) *gorm.Config

type PoolsConfig

type PoolsConfig struct {
	MaxOpenConns int `yaml:"maxOpenConns"`
	MaxIdleConns int `yaml:"maxIdleConns"`
	ConnLifeTime int `yaml:"connLifeTime"`
	ConnIdleTime int `yaml:"connIdleTime"`
}

type RootConfig

type RootConfig struct {
	Api AppConfig `yaml:"api"`
}

定义你的YAML结构

type RouteConfig

type RouteConfig struct {
	Url     string `yaml:url`
	Method  string `yaml:"method"`
	Handler string `yaml:"handler"`
}

Jump to

Keyboard shortcuts

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