config

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

日志相关配置

Index

Constants

View Source
const (
	DefaultAppName    = "application"
	DefaultServerType = "backend"
	DefaultPort       = 9445
)

Variables

This section is empty.

Functions

func LoadGlobalConfig

func LoadGlobalConfig(cfgPath string) (err error)

Types

type DBConfg added in v1.6.0

type DBConfg struct {
	DBType   DBTYPE `toml:"db_type" json:"db_type" env:"ORM_DBTYPE"`     // dbtype
	User     string `toml:"user" json:"user" env:"ORM_USER"`             // user
	Password string `toml:"password" json:"password" env:"ORM_PASSWORD"` // password
	Host     string `toml:"host" json:"host" env:"ORM_HOST"`             // host
	Port     string `toml:"port" json:"port" env:"ORM_PORT"`             // port
	Database string `toml:"database" json:"database" env:"ORM_DATABASE"` // database
	CaCert   string `toml:"ca_cert" json:"ca_cert" env:"ORM_CACERT"`     // cacert
}

DBConfg represents a database configuration

func (DBConfg) DefaultConfig added in v1.6.0

func (db DBConfg) DefaultConfig() DBConfg

func (DBConfg) TOML added in v1.6.0

func (db DBConfg) TOML() string

type DBTYPE added in v1.6.0

type DBTYPE string
const (
	MYSQL    DBTYPE = "mysql"
	SQLITE3  DBTYPE = "sqlite3"
	POSTGRES DBTYPE = "postgres"
)

type Discovery

type Discovery struct {
	Namespace   string         `toml:"namespace" json:"namespace" env:"DISCOVERY_NAMESPACE"`         // 命名空间
	Endpoints   []string       `toml:"endpoints" json:"endpoints" env:"DISCOVERY_ENDPOINTS"`         // 连接端点
	DialTimeout utils.Duration `toml:"dial_timeout" json:"dial_timeout" env:"DISCOVERY_DIALTIMEOUT"` // 连接超时时间
}

func (Discovery) DefaultConfig

func (ds Discovery) DefaultConfig() Discovery

func (Discovery) TOML

func (ds Discovery) TOML() string

type GinConfig

type GinConfig struct {
	App                 string         `toml:"app" json:"app" env:"GIN_APP"`                                               // application
	ServerType          string         `toml:"server_type" json:"server_type" env:"GIN_SERVERTYPE"`                        // 服务类型
	EnablePprof         bool           `toml:"enable_pprof" json:"enable_pprof" env:"GIN_ENABLEPPROF"`                     // pprof开关
	EnableHealth        bool           `toml:"enable_health" json:"enable_health" env:"GIN_ENABLEHEALTH"`                  // health开关
	EnableDebug         bool           `toml:"enable_debug" json:"enable_debug" env:"GIN_ENABLEDEBUG"`                     // debug开关
	EnableMetrics       bool           `toml:"enable_metrics" json:"enable_metrics" env:"GIN_ENABLEMETRICS"`               // metrics开关
	EnableCache         bool           `toml:"enable_cache" json:"enable_cache" env:"GIN_ENABLECACHE"`                     // 缓存开关
	EnableAuth          bool           `toml:"enable_auth" json:"enable_auth" env:"GIN_ENABLEAUTH"`                        // 签名权限开关
	EnableVerifyCommand bool           `toml:"enable_verify_command" json:"enable_verify_command" env:"GIN_VERIFYCOMMAND"` // 指令验证开关
	Port                int            `toml:"port" json:"port" env:"GIN_PORT"`                                            // port
	Trace               string         `toml:"trace" json:"trace" env:"GIN_TRACE"`                                         // Trace
	GracefulTimeout     utils.Duration `toml:"graceful_timeout" json:"graceful_timeout" env:"GIN_GRACEFULTIMEOUT"`         // GracefulTimeout
}

func (GinConfig) DefaultConfig

func (gcf GinConfig) DefaultConfig() GinConfig

func (GinConfig) ListenAddr

func (gcf GinConfig) ListenAddr() string

func (GinConfig) TOML

func (gcf GinConfig) TOML() string

type Global

type Global struct {
	Logging   `toml:"logging"`
	Metrics   `toml:"metrics"`
	Discovery `toml:"discovery"`
	GinConfig `toml:"gin"`
	RateLimit `toml:"ratelimit"`
	Temporary `toml:"temporary"`
	DBConfg   `toml:"database"`
}
var GlobalCfg Global

func (Global) TOML

func (g Global) TOML() string

type Logging

type Logging struct {
	IsTerminal bool   `toml:"isterminal" json:"isterminal" env:"LOGGING_ISTERMINAL"` // debug模式stdout输出
	Dir        string `toml:"dir" json:"dir" env:"LOGGING_DIR"`                      // 日志目录
	Filename   string `toml:"name" json:"name" env:"LOGGING_FILENAME"`               // 日志名称
	Level      string `toml:"level" json:"level" env:"LOGGING_LEVEL"`                // 打印日志等级
	MaxSize    uint16 `toml:"maxsize" json:"maxsize" env:"LOGGING_MAXSIZE"`          // 单日志尺寸
	MaxBackups uint16 `toml:"maxbackups" json:"maxbackups" env:"LOGGING_MAXBACKUPS"` // 日志备份数
	MaxAge     uint16 `toml:"maxage" json:"maxage" env:"LOGGING_MAXAGE"`             // 留旧日志文件的最大天数
}

Logging represents a logging configuration

func (Logging) DefaultConfig

func (l Logging) DefaultConfig() Logging

func (Logging) TOML

func (l Logging) TOML() string

type Metrics

type Metrics struct {
	FlushInterval          time.Duration     `toml:"flush_interval" json:"flush_interval" env:"METRICS_FLUSHINTERVAL"`                              // flush时间周期
	EnableGoRuntimeMetrics bool              `toml:"enable_goruntime_metrics" json:"enable_goruntime_metrics" env:"METRICS_ENABLEGORUNTIMEMETRICS"` // 是否收集goroutine相关信息
	MetricsPrefix          string            `toml:"metrics_prefix" json:"metrics_prefix" env:"METRICS_METRICSPREFIX"`                              // 自定义metric指标前缀
	MetricsTags            map[string]string `toml:"metrics_tags" json:"metrics_tags" env:"METRICS_METRICSTAGS"`                                    // 自定义metric自动填充kv数据
}

Metrics represents a logging configuration

func (Metrics) DefaultConfig

func (l Metrics) DefaultConfig() Metrics

func (Metrics) TOML

func (l Metrics) TOML() string

type RateLimit

type RateLimit struct {
	QPS   int `toml:"qps" json:"qps" env:"GIN_RATELIMIT_QPS"`       // qps
	Burst int `toml:"burst" json:"burst" env:"GIN_RATELIMIT_BURST"` // 并发数
}

func (RateLimit) DefaultConfig

func (rl RateLimit) DefaultConfig() RateLimit

func (RateLimit) TOML

func (rl RateLimit) TOML() string

type Temporary

type Temporary struct {
	MaxBufferSize int64  `toml:"max_buffer_size" json:"max_buffer_size" env:"TEMPORARY_MAX_BUFFER_SIZE"` // 最大使用内存空间, 超过时则转化成文件
	FileDir       string `toml:"file_dir" json:"file_dir" env:"TEMPORARY_FILE_DIR"`                      // 临时文件目录
	FilePattern   string `toml:"file_pattern" json:"file_pattern" env:"TEMPORARY_FILE_PATTERN"`          // 临时文件名格式
	MaxUploadSize int64  `toml:"max_upload_size" json:"max_upload_size" env:"TEMPORARY_MAX_UPLOAD_SIZE"` // 最大上传文件大小
}

Temporary represents a logging configuration

func (Temporary) DefaultConfig

func (l Temporary) DefaultConfig() Temporary

func (Temporary) TOML

func (l Temporary) TOML() string

Directories

Path Synopsis
配置加载后, 联动更新各个模块的全局变量.
配置加载后, 联动更新各个模块的全局变量.

Jump to

Keyboard shortcuts

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