config

package
v0.0.0-...-1764b58 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	AuthServiceURL string `mapstructure:"auth_service_url"`
}

type Config

type Config struct {
	Server   ServerConfig   `mapstructure:"server"`
	Database DatabaseConfig `mapstructure:"database"`
	Redis    RedisConfig    `mapstructure:"redis"`
	Auth     AuthConfig     `mapstructure:"auth"`
	JWT      JWTConfig      `mapstructure:"jwt"`
	Log      LogConfig      `mapstructure:"log"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig 加载配置文件

type DatabaseConfig

type DatabaseConfig struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
	DBName   string `mapstructure:"dbname"`
	SSLMode  string `mapstructure:"sslmode"`
}

type JWTConfig

type JWTConfig struct {
	Secret             string `mapstructure:"secret"`
	ExpireHours        int    `mapstructure:"expire_hours"`
	RefreshExpireHours int    `mapstructure:"refresh_expire_hours"`
}

func (JWTConfig) ExpireDuration

func (j JWTConfig) ExpireDuration() time.Duration

func (JWTConfig) RefreshExpireDuration

func (j JWTConfig) RefreshExpireDuration() time.Duration

type LogConfig

type LogConfig struct {
	Level       string `mapstructure:"level" json:"level" yaml:"level"`                   // 日志级别: debug, info, warn, error
	Format      string `mapstructure:"format" json:"format" yaml:"format"`                // 输出格式: json, text
	Output      string `mapstructure:"output" json:"output" yaml:"output"`                // 输出位置: stdout, file
	FilePath    string `mapstructure:"file_path" json:"file_path" yaml:"file_path"`       // 文件路径
	MaxSize     int    `mapstructure:"max_size" json:"max_size" yaml:"max_size"`          // 文件最大大小(MB)
	MaxBackups  int    `mapstructure:"max_backups" json:"max_backups" yaml:"max_backups"` // 保留文件数量
	MaxAge      int    `mapstructure:"max_age" json:"max_age" yaml:"max_age"`             // 文件保留天数
	Compress    bool   `mapstructure:"compress" json:"compress" yaml:"compress"`          // 是否压缩
	ServiceName string `json:"service_name" yaml:"service_name"`                          // 服务名称
}

LogConfig 日志配置 - 匹配 common/go/logger.Config

type RedisConfig

type RedisConfig struct {
	Addr     string `mapstructure:"addr"`
	Password string `mapstructure:"password"`
	DB       int    `mapstructure:"db"`
}

type ServerConfig

type ServerConfig struct {
	Port     int    `mapstructure:"port"`
	GRPCPort int    `mapstructure:"grpc_port"`
	Mode     string `mapstructure:"mode"`
}

Jump to

Keyboard shortcuts

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