configs

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseDriver       = "database.driver"
	DatabaseHost         = "database.host"
	DatabasePort         = "database.port"
	DatabaseUserName     = "database.username"
	DatabasePassword     = "database.password"
	DatabaseDbName       = "database.dbName"
	DatabaseConfig       = "database.config"
	DatabaseMaxIdleConns = "database.maxIdleConns"
	DatabaseMaxOpenConns = "database.maxOpenConns"
	DatabaseShowSQL      = "database.showSql"
)

Variables

This section is empty.

Functions

func Env

func Env(key string, value ...interface{}) interface{}

func EnvBool

func EnvBool(key string, value ...interface{}) bool

func EnvInt

func EnvInt(key string, value ...interface{}) int

func EnvString

func EnvString(key string, value ...interface{}) string

func EnvStringSlice

func EnvStringSlice(key string, value ...interface{}) []string

Types

type CacheConfig

type CacheConfig struct {
	MemoryCacheSize int           // 内存缓存大小(字节)
	RedisAddr       string        // Redis 地址
	RedisPassword   string        // Redis 密码
	RedisDB         int           // Redis 数据库编号
	RedisPrefix     string        // Redis 键前缀
	MaxActive       int           // Redis 最大活动连接数
	MaxIdle         int           // Redis 最大空闲连接数
	Timeout         time.Duration // Redis 连接超时时间
}

CacheConfig 结构体用于存储缓存系统的配置

func LoadCacheConfig

func LoadCacheConfig() *CacheConfig

type ConfigEntity

type ConfigEntity struct {
	// contains filtered or unexported fields
}

ConfigEntity 表示需要全局调用的实体对象

func GetInstance

func GetInstance() *ConfigEntity

GetInstance 返回 ConfigDataEntity 的单例实例

func (*ConfigEntity) Get

func (c *ConfigEntity) Get(key string, defaultValue ...interface{}) interface{}

Get 获取interface{}类型配置

func (*ConfigEntity) GetBool

func (c *ConfigEntity) GetBool(key string, defaultValue ...bool) bool

GetBool 获取bool类型配置

func (*ConfigEntity) GetConfig

func (c *ConfigEntity) GetConfig() *viper.Viper

func (*ConfigEntity) GetDuration

func (c *ConfigEntity) GetDuration(key string, defaultValue ...time.Duration) time.Duration

GetDuration 获取time.Duration类型配置

func (*ConfigEntity) GetFloat64

func (c *ConfigEntity) GetFloat64(key string, defaultValue ...float64) float64

GetFloat64 获取float64类型配置

func (*ConfigEntity) GetInt

func (c *ConfigEntity) GetInt(key string, defaultValue ...int) int

GetInt 获取int类型配置

func (*ConfigEntity) GetIntSlice

func (c *ConfigEntity) GetIntSlice(key string, defaultValue ...[]int) []int

GetIntSlice 获取[]int类型配置

func (*ConfigEntity) GetString

func (c *ConfigEntity) GetString(key string, defaultValue ...string) string

GetString 获取string类型配置

func (*ConfigEntity) GetStringMap

func (c *ConfigEntity) GetStringMap(key string, defaultValue ...map[string]interface{}) map[string]interface{}

GetStringMap 获取map[string]interface{}类型配置

func (*ConfigEntity) GetStringMapString

func (c *ConfigEntity) GetStringMapString(key string, defaultValue ...map[string]string) map[string]string

GetStringMapString 获取map[string]string类型配置

func (*ConfigEntity) GetStringSlice

func (c *ConfigEntity) GetStringSlice(key string, defaultValue ...[]string) []string

GetStringSlice 获取[]string类型配置

func (*ConfigEntity) GetTime

func (c *ConfigEntity) GetTime(key string, defaultValue ...time.Time) time.Time

GetTime 获取time.Time类型配置

type Local

type Local struct {
	Path      string `mapstructure:"path" json:"path" yaml:"path"`
	StorePath string `mapstructure:"storePath" json:"storePath" yaml:"storePath"`
}

func (Local) WeaverMarshal

func (Local) WeaverMarshal(*codegen.Encoder)

func (Local) WeaverUnmarshal

func (Local) WeaverUnmarshal(*codegen.Decoder)

type LogConfig

type LogConfig struct {
	Level     string    `mapstructure:"level" json:"level" yaml:"level"`
	Pattern   string    `mapstructure:"pattern" json:"pattern" yaml:"pattern"`
	Output    string    `mapstructure:"output" json:"output" yaml:"output"`
	LogRotate LogRotate `mapstructure:"logRotate" json:"logRotate" yaml:"logRotate"`
}

func LoadLogConfig

func LoadLogConfig() *LogConfig

func (LogConfig) WeaverMarshal

func (LogConfig) WeaverMarshal(*codegen.Encoder)

func (LogConfig) WeaverUnmarshal

func (LogConfig) WeaverUnmarshal(*codegen.Decoder)

type LogRotate

type LogRotate struct {
	Filename   string `mapstructure:"filename" json:"filename" yaml:"filename"`
	MaxSize    int    `mapstructure:"maxSize" json:"maxSize" yaml:"maxSize"`
	MaxBackups int    `mapstructure:"maxBackups" json:"maxBackups" yaml:"maxBackups"`
	MaxAge     int    `mapstructure:"maxAge" json:"maxAge" yaml:"maxAge"`
	Compress   bool   `mapstructure:"compress" json:"compress" yaml:"compress"`
}

type ModCaptcha

type ModCaptcha struct {
	KeyLong            int `mapstructure:"keyLong" json:"keyLong" yaml:"keyLong"`
	ImgWidth           int `mapstructure:"imgWidth" json:"imgWidth" yaml:"imgWidth"`
	ImgHeight          int `mapstructure:"imgHeight" json:"imgHeight" yaml:"imgHeight"`
	OpenCaptcha        int `mapstructure:"openCaptcha" json:"openCaptcha" yaml:"openCaptcha"`
	OpenCaptchaTimeOut int `mapstructure:"openCaptchaTimeout" json:"openCaptchaTimeout" yaml:"openCaptchaTimeout"`
}

func (ModCaptcha) WeaverMarshal

func (ModCaptcha) WeaverMarshal(*codegen.Encoder)

func (ModCaptcha) WeaverUnmarshal

func (ModCaptcha) WeaverUnmarshal(*codegen.Decoder)

type ModGormDb

type ModGormDb struct {
	Driver       string `mapstructure:"driver" json:"driver" yaml:"driver"`
	Host         string `mapstructure:"host" json:"host" yaml:"host"`
	Port         string `mapstructure:"port" json:"port" yaml:"port"`
	Username     string `mapstructure:"username" json:"username" yaml:"username"`
	Password     string `mapstructure:"password" json:"password" yaml:"password"`
	Dbname       string `mapstructure:"dbName" json:"dbName" yaml:"dbName"`
	Config       string `mapstructure:"config" json:"config" yaml:"config"`
	Prefix       string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
	Singular     bool   `mapstructure:"singular" json:"singular" yaml:"singular"`
	Engine       string `mapstructure:"engine" json:"engine" yaml:"engine" default:"InnoDB"`
	MaxIdleConns int    `mapstructure:"maxIdleConns" json:"maxIdleConns" yaml:"maxIdleConns"`
	MaxOpenConns int    `mapstructure:"maxOpenConns" json:"maxOpenConns" yaml:"maxOpenConns"`
	LogMode      string `mapstructure:"logMode" json:"logMode" yaml:"logMode"`
	LogZap       bool   `mapstructure:"logZap" json:"logZap" yaml:"logZap"`
	Dsn          string
	ShowSQL      bool
}

func LoadDatabaseConfig

func LoadDatabaseConfig() *ModGormDb

func (*ModGormDb) SetDsn

func (m *ModGormDb) SetDsn()

func (ModGormDb) WeaverMarshal

func (ModGormDb) WeaverMarshal(*codegen.Encoder)

func (ModGormDb) WeaverUnmarshal

func (ModGormDb) WeaverUnmarshal(*codegen.Decoder)

type ModJwt

type ModJwt struct {
	SigningKey  string `mapstructure:"signingKey" json:"signingKey" yaml:"signingKey"`    // --jwt签名
	ExpiresTime string `mapstructure:"expiresTime" json:"expiresTime" yaml:"expiresTime"` // --过期时间
	BufferTime  string `mapstructure:"bufferTime" json:"bufferTime" yaml:"bufferTime"`    // --缓冲时间
	Issuer      string `mapstructure:"issuer" json:"issuer" yaml:"issuer"`                // --签发者
}

func (ModJwt) WeaverMarshal

func (ModJwt) WeaverMarshal(*codegen.Encoder)

func (ModJwt) WeaverUnmarshal

func (ModJwt) WeaverUnmarshal(*codegen.Decoder)

type ModRedis

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

func (ModRedis) WeaverMarshal

func (ModRedis) WeaverMarshal(*codegen.Encoder)

func (ModRedis) WeaverUnmarshal

func (ModRedis) WeaverUnmarshal(*codegen.Decoder)

type ModSwaConfig

type ModSwaConfig struct {
	Jwt     ModJwt     `mapstructure:"jwt" json:"jwt" toml:"jwt"`
	Redis   ModRedis   `mapstructure:"redis" json:"redis" toml:"redis"`
	Captcha ModCaptcha `mapstructure:"captcha" json:"captcha" toml:"captcha"`
	GormDB  ModGormDb  `mapstructure:"gormDB" json:"gormDB" toml:"gormDB"`
	System  ModSystem  `mapstructure:"system" json:"system" toml:"system"`
	Local   Local      `mapstructure:"local" json:"local" toml:"local"`
	Log     LogConfig  `mapstructure:"log" json:"log" toml:"log"`
}

func (ModSwaConfig) WeaverMarshal

func (ModSwaConfig) WeaverMarshal(*codegen.Encoder)

func (ModSwaConfig) WeaverUnmarshal

func (ModSwaConfig) WeaverUnmarshal(*codegen.Decoder)

type ModSystem

type ModSystem struct {
	Debug                  bool   `mapstructure:"debug" json:"debug" yaml:"debug"`
	EnablePProf            bool   `mapstructure:"enablePProf" json:"enablePProf" yaml:"enablePProf"`
	PprofPort              string `mapstructure:"pprofPort" json:"pprofPort" yaml:"pprofPort"`
	Env                    string `mapstructure:"env" json:"env" yaml:"env"`
	Addr                   int    `mapstructure:"addr" json:"addr" yaml:"addr"`
	DbType                 string `mapstructure:"dbType" json:"dbType" yaml:"dbType"`
	OssType                string `mapstructure:"ossType" json:"ossType" yaml:"ossType"`
	UseMultipoint          bool   `mapstructure:"useMultipoint" json:"useMultipoint" yaml:"useMultipoint"`
	UseRedis               bool   `mapstructure:"useRedis" json:"useRedis" yaml:"useRedis"`
	LimitCountIP           int    `mapstructure:"ipLimitCount" json:"ipLimitCount" yaml:"ipLimitCount"`
	LimitTimeIP            int    `mapstructure:"ipLimitTime" json:"ipLimitTime" yaml:"ipLimitTime"`
	RouterPrefix           string `mapstructure:"routerPrefix" json:"routerPrefix" yaml:"routerPrefix"`
	ResourceCachingEnabled bool   `mapstructure:"resourceCachingEnabled" json:"resourceCachingEnabled" yaml:"resourceCachingEnabled"`
}

func (ModSystem) WeaverMarshal

func (ModSystem) WeaverMarshal(*codegen.Encoder)

func (ModSystem) WeaverUnmarshal

func (ModSystem) WeaverUnmarshal(*codegen.Decoder)

type MqttConfig

type MqttConfig struct {
	Host         string `json:"host"`
	UserName     string `json:"user_name"`
	PassWord     string `json:"pass_word"`
	ClientID     string `json:"client_id"`
	Parallel     bool   `json:"parallel"`
	SubscribeQos uint8  `json:"subscribe_qos"`
	PublishQos   uint8  `json:"publish_qos"`
}

func LoadMqttConfig

func LoadMqttConfig() *MqttConfig

type QueueConfig

type QueueConfig struct {
	Prefix      string
	Listen      []string
	Interval    time.Duration
	Concurrency int
}

func LoadQueueConfig

func LoadQueueConfig() *QueueConfig

type RedisConfig

type RedisConfig struct {
	Mode               string
	SentinelMasterName string
	Addr               string
	Auth               string
	Db                 int
	MaxActive          int
	MaxIdle            int
	IdleTimeout        time.Duration
}

func LoadRedisConfig

func LoadRedisConfig() *RedisConfig

type TokenConfig

type TokenConfig struct {
	Key string `json:"key"`
	Exp int64  `json:"exp"`
}

func LoadTokenConfig

func LoadTokenConfig() *TokenConfig

type WebSocketConfig

type WebSocketConfig struct {
	WebSocketHost string `json:"webSocketHost"`
	WebSocketPort string `json:"webSocketPort"`
	Path          string
}

func LoadWebSocketConfig

func LoadWebSocketConfig() *WebSocketConfig

Jump to

Keyboard shortcuts

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