Documentation ¶
Index ¶
- Variables
- func GetRedisClient() *redis.Client
- func SetRedisClient(c *redis.Client)
- func Setup(fs ...SetOptionFuc)
- type AliyunOSS
- type Application
- type Cache
- type Casbin
- type Config
- type DBResolverConfig
- type Database
- type Demo
- type Extend
- type Filesystem
- type Jwt
- type Locker
- type Logger
- type LoggerCut
- type Minio
- type Qiniu
- type Queue
- type QueueMemory
- type QueueNSQ
- type QueueRedis
- type Redis
- type SetOptionFuc
- type System
- type Tls
- type Zap
Constants ¶
This section is empty.
Variables ¶
View Source
var ApplicationConfig = new(Application)
View Source
var CacheConfig = new(Cache)
View Source
var CasbinConfig = new(Casbin)
View Source
var ExtConfig = new(Extend)
View Source
var FilesystemConfig = new(Filesystem)
View Source
var JwtConfig = new(Jwt)
View Source
var LockerConfig = new(Locker)
View Source
var LoggerConfig = new(Logger)
View Source
var QueueConfig = new(Queue)
Functions ¶
func Setup ¶
func Setup(fs ...SetOptionFuc)
Setup @description Setup 载入配置文件 @auth cpYun 时间(2022/7/22 10:00 ) @param s string "配置文件路径" @param fs func "回调函数" @return
Types ¶
type Application ¶
type Application struct { Mode string `json:"mode" yaml:"mode"` //环境配置 dev开发环境 test测试环境 prod线上环境 Host string `json:"host" yaml:"host"` // 服务器ip,默认使用 0.0.0.0 Port int `json:"port" yaml:"port"` // 端口号 Name string `json:"name" yaml:"name"` // 服务名称 ReadTimeout int `json:"read-timeout" yaml:"read-timeout"` // 读超时 WriteTimeout int `json:"write-timeout" yaml:"write-timeout"` // 写超时 EnableDp bool `json:"enable-dp" yaml:"enable-dp"` // 数据权限功能开关 }
type Config ¶
type Config struct { Application *Application `mapstructure:"application" json:"application" yaml:"application"` Database *Database `json:"database" yaml:"database"` Databases *map[string]*Database `json:"databases" yaml:"databases"` Logger *Logger `mapstructure:"logger" json:"logger" yaml:"logger"` Cache *Cache `mapstructure:"cache" yaml:"cache" json:"cache"` Filesystem *Filesystem `mapstructure:"filesystem" json:"mysql" yaml:"filesystem"` Queue *Queue `json:"queue" yaml:"queue"` Locker *Locker `json:"locker" yaml:"locker"` JWT *Jwt `mapstructure:"jwt" json:"jwt" yaml:"jwt"` Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"` Casbin *Casbin `mapstructure:"casbin" json:"casbin" yaml:"casbin"` Extend interface{} `yaml:"extend"` // contains filtered or unexported fields }
var ( ExtendConfig interface{} Settings *Config )
type DBResolverConfig ¶
type DBResolverConfig struct { Sources []string `mapstructure:"sources" json:"sources" yaml:"sources"` Replicas []string `mapstructure:"replicas" json:"replicas" yaml:"replicas"` Policy string `mapstructure:"policy" json:"policy" yaml:"policy"` Tables []string `mapstructure:"tables" json:"tables" yaml:"tables"` }
type Database ¶
type Database struct { Driver string `mapstructure:"driver" json:"driver" yaml:"driver"` Source string `mapstructure:"source" json:"source" yaml:"source"` ConnMaxIdleTime int `mapstructure:"conn-max-idle-time" json:"conn-max-idle-time" yaml:"conn-max-idle-time"` ConnMaxLifeTime int `mapstructure:"conn-max-life-time" json:"conn-max-life-time" yaml:"conn-max-life-time"` MaxIdleConns int `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"` // 空闲中的最大连接数 MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数 LoggerMode string `mapstructure:"logger-mode" json:"logger-mode" yaml:"logger-mode"` Registers []DBResolverConfig `mapstructure:"registers" json:"registers" yaml:"registers"` }
type Extend ¶
type Extend struct {
Demo Demo // 这里配置对应配置文件的结构即可
}
Extend 扩展配置
extend: demo: name: demo-name
Example: config.ExtConfig......!!
type Filesystem ¶
type Jwt ¶
type Jwt struct { SigningKey string `mapstructure:"signing-key" json:"signing-key" yaml:"signing-key"` // jwt签名 ExpiresTime int64 `mapstructure:"expires-time" json:"expires-time" yaml:"expires-time"` // 过期时间 BufferTime int64 `mapstructure:"buffer-time" json:"buffer-time" yaml:"buffer-time"` // 缓冲时间 Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"` // 签发者 }
type Logger ¶
type Logger struct { Type string `mapstructure:"type" json:"type" yaml:"type"` Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别 TimeFormat string `mapstructure:"time-format" json:"time-format" yaml:"time-format"` // 时间格式 Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀 Path string `mapstructure:"path" json:"path" yaml:"path"` // 日志文件 ShowLine bool `mapstructure:"show-line" json:"show-line" yaml:"show-line"` // 显示行 EncodeLevel string `mapstructure:"encode-level" json:"encode-level" yaml:"encode-level"` // 编码级 StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktrace-key" yaml:"stacktrace-key"` // 栈名 Stdout string `mapstructure:"stdout" json:"stdout" yaml:"stdout"` // 输出控制台 Cut LoggerCut `mapstructure:"cut" json:"cut" yaml:"cut"` // 日志裁切 }
type LoggerCut ¶
type LoggerCut struct { Cap uint `mapstructure:"cap" json:"cap" yaml:"cap"` // 裁切 MB MaxAge uint `mapstructure:"max-age" json:"max-age" yaml:"max-age"` // 最大备份天数 MaxBackups uint `mapstructure:"max-age" json:"max-backups" yaml:"max-backups"` // 最大备份数 Compress bool `mapstructure:"compress" json:"compress" yaml:"compress"` // 是否压缩 }
type Minio ¶
type Minio struct { Endpoint string AccessKeyID string `mapstructure:"access-key-id" json:"access-key-id" yaml:"access-key-id"` SecretAccessKey string `mapstructure:"secret-access-key" json:"secret-access-key" yaml:"secret-access-key"` Secure bool `mapstructure:"secure" json:"secure" yaml:"secure"` Region string `mapstructure:"region" json:"region" yaml:"region"` Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` }
type Queue ¶
type Queue struct { Redis *QueueRedis Memory *QueueMemory NSQ *QueueNSQ `json:"nsq" yaml:"nsq"` }
type QueueMemory ¶
type QueueMemory struct {
PoolSize uint
}
type QueueRedis ¶
type QueueRedis struct { Redis Producer *redisqueue.ProducerOptions Consumer *redisqueue.ConsumerOptions }
type Redis ¶
type Redis struct { Network string `yaml:"network" json:"network"` // Addr string `yaml:"addr" json:"addr"` // 服务器地址:端口 Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` DB int `yaml:"db" json:"db"` PoolSize int `yaml:"pool-size" json:"pool-size"` Tls *Tls `yaml:"tls" json:"tls"` MaxRetries int `yaml:"max-retries" json:"max-retries"` }
func (Redis) GetRedisOptions ¶
type SetOptionFuc ¶
type SetOptionFuc func(*setOptions)
func WithCallback ¶
func WithCallback(fs ...func()) SetOptionFuc
func WithSource ¶
func WithSource(s ...source.Source) SetOptionFuc
type System ¶
type System struct { Env string `mapstructure:"env" json:"env" yaml:"env"` // 环境值 Addr int `mapstructure:"addr" json:"addr" yaml:"addr"` // 端口值 DatabaseDriver string `mapstructure:"database-driver" json:"database-driver" yaml:"database-driver"` // 数据库类型:mysql(默认)|sqlite|sqlserver|postgresql OssType string `mapstructure:"oss-type" json:"oss-type" yaml:"oss-type"` // Oss类型 UseMultipoint bool `mapstructure:"use-multipoint" json:"use-multipoint" yaml:"use-multipoint"` // 多点登录拦截 UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"` // 使用redis LimitCountIP int `mapstructure:"iplimit-count" json:"iplimit-count" yaml:"iplimit-count"` LimitTimeIP int `mapstructure:"iplimit-time" json:"iplimit-time" yaml:"iplimit-time"` }
System Deprecated: Use Application instead
type Zap ¶
type Zap struct { Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别 Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出 Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀 Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹 ShowLine bool `mapstructure:"show-line" json:"show-line" yaml:"show-line"` // 显示行 EncodeLevel string `mapstructure:"encode-level" json:"encode-level" yaml:"encode-level"` // 编码级 StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktrace-key" yaml:"stacktrace-key"` // 栈名 LogInConsole bool `mapstructure:"log-in-console" json:"log-in-console" yaml:"log-in-console"` // 输出控制台 }
Zap Deprecated: Use Logger instead
Source Files ¶
Click to show internal directories.
Click to hide internal directories.