Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLogMode ¶
Types ¶
type AccessLimit ¶
type AccessLimit struct {
Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` //是否启用
Duration time.Duration `mapstructure:"duration" json:"duration" yaml:"duration"` //时长周期
Total int `mapstructure:"total" json:"total" yaml:"total"` //周期内最大访问次数,超过拒绝
}
func (*AccessLimit) GetDuration ¶
func (s *AccessLimit) GetDuration() time.Duration
func (*AccessLimit) GetTotal ¶
func (s *AccessLimit) GetTotal() int
type AppCfg ¶
type AppCfg struct {
Server ServerCfg `mapstructure:"server" json:"server" yaml:"server"` //服务器配置
Remote RemoteCfg `mapstructure:"remote" json:"remote" yaml:"remote"` //远程配置
Logger LogCfg `mapstructure:"logger" json:"logger" yaml:"logger"` //log配置
JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"` //jwt配置
DBCfg DBCfg `mapstructure:"dbcfg" json:"dbcfg" yaml:"dbcfg"` // 数据库配置
Cache CacheCfg `mapstructure:"cache" json:"cache" yaml:"cache"` // 缓存
Cors CORS `mapstructure:"cors" json:"cors" yaml:"cors"` //cors配置
Extends any `mapstructure:"extend" json:"extend" yaml:"extend"` //扩展配置
Gen GenCfg `mapstructure:"gen" json:"gen" yaml:"gen"` //是否可生成
GrpcServer GrpcServerCfg `mapstructure:"grpc-server" json:"grpc-server" yaml:"grpc-server"` //grpc服务配置
AccessLimit AccessLimit `mapstructure:"access-limit" json:"access-limit" yaml:"access-limit"` //访问限制配置
}
type CORS ¶
type CORS struct {
Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"`
Mode string `mapstructure:"mode" json:"mode" yaml:"mode"`
Whitelist []CORSWhitelist `mapstructure:"whitelist" json:"whitelist" yaml:"whitelist"`
}
type CORSWhitelist ¶
type CORSWhitelist struct {
AllowOrigin string `mapstructure:"allow-origin" json:"allow-origin" yaml:"allow-origin"`
AllowMethods string `mapstructure:"allow-methods" json:"allow-methods" yaml:"allow-methods"`
AllowHeaders string `mapstructure:"allow-headers" json:"allow-headers" yaml:"allow-headers"`
ExposeHeaders string `mapstructure:"expose-headers" json:"expose-headers" yaml:"expose-headers"`
AllowCredentials bool `mapstructure:"allow-credentials" json:"allow-credentials" yaml:"allow-credentials"`
}
type CacheCfg ¶
type CacheCfg struct {
Type string `mapstructure:"type" json:"type" yaml:"type"`
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
DB int `mapstructure:"db" json:"db" yaml:"db"`
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
MasterName string `mapstructure:"master-name" json:"master-name" yaml:"master-name"`
}
type Config ¶
type Config struct {
Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"`
Driver string `mapstructure:"driver" json:"driver" yaml:"driver"`
Endpoints []string `mapstructure:"endpoints" json:"endpoints" yaml:"endpoints"`
Scheme string `mapstructure:"scheme" json:"scheme" yaml:"scheme"`
Timeout time.Duration `mapstructure:"timeout" json:"timeout" yaml:"timeout"`
Registers []*RegisterNode `mapstructure:"registers" json:"registers" yaml:"registers"`
Discoveries []*DiscoveryNode `mapstructure:"discoveries" json:"discoveries" yaml:"discoveries"`
}
type DB ¶
type DB struct {
DSN string `mapstructure:"dsn" json:"dsn" yaml:"dsn"` //连接参数
Disable bool `mapstructure:"disable" json:"disable" yaml:"disable"` //是否启用 默认true
Driver string `mapstructure:"driver" json:"driver" yaml:"driver"` //数据库类型
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` //全局表前缀,单独定义TableName则不生效
MaxIdleConn int `mapstructure:"max-idle-conn" json:"max-idle-conn" yaml:"max-idle-conn"` // 空闲中的最大连接数
MaxOpenConn int `mapstructure:"max-open-conn" json:"max-open-conn" yaml:"max-open-conn"` // 打开到数据库的最大连接数
MaxLifetime int `mapstructure:"max-lifetime" json:"max-lifetime" yaml:"max-lifetime"` // 链接重置时间(分)
LogMode string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"` // Gorm日志级别: silent、error、warn、info
IgnoreNotFound bool `mapstructure:"ignore-not-found" json:"ignore-not-found" yaml:"ignore-not-found"` //忽略无记录错误
SlowThreshold int `mapstructure:"slow-threshold" json:"slow-threshold" yaml:"slow-threshold"` // 慢查询 毫秒 大于0有效
DryRun bool `mapstructure:"dry-run" json:"dry-run" yaml:"dry-run"` //
}
type DBCfg ¶
type DBCfg struct {
DSN string `mapstructure:"dsn" json:"dsn" yaml:"dsn"` //连接参数
Driver string `mapstructure:"driver" json:"driver" yaml:"driver"` //数据库类型
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` //全局表前缀,单独定义TableName则不生效
Singular bool `mapstructure:"singular" json:"singular" yaml:"singular"` //是否开启全局禁用复数,true表示开启
MaxIdleConns int `mapstructure:"max-idle-conn" json:"max-idle-conn" yaml:"max-idle-conn"` // 空闲中的最大连接数
MaxOpenConns int `mapstructure:"max-open-conn" json:"max-open-conn" yaml:"max-open-conn"` // 打开到数据库的最大连接数
MaxLifetime int `mapstructure:"max-lifetime" json:"max-lifetime" yaml:"max-lifetime"` // 链接重置时间(分)
LogMode string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"` // Gorm日志级别: silent、error、warn、info
SlowThreshold int `mapstructure:"slow-threshold" json:"slow-threshold" yaml:"slow-threshold"` // 慢查询 毫秒 大于0有效
IgnoreNotFound bool `mapstructure:"ignore-not-found" json:"ignore-not-found" yaml:"ignore-not-found"` //忽略无记录错误
DryRun bool `mapstructure:"dry-run" json:"dry-run" yaml:"dry-run"` //
LogLinePrefix string `mapstructure:"log-line-prefix" json:"log-line-prefix" yaml:"log-line-prefix"` //
DBS map[string]DB `mapstructure:"dbs" json:"dbs" yaml:"dbs"` //配置多db
}
func (*DBCfg) GetMaxIdleConn ¶
func (*DBCfg) GetMaxLifetime ¶
func (*DBCfg) GetMaxOpenConn ¶
type DiscoveryNode ¶
type DiscoveryNode struct {
Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` //启用发现
Namespace string `mapstructure:"namespace" json:"namespace" yaml:"namespace"` //命名空间
Name string `mapstructure:"name" json:"name" yaml:"name"` //服务名
Tag string `mapstructure:"tag" json:"tag" yaml:"tag"` //标签
SchedulingAlgorithm string `mapstructure:"scheduling-algorithm" json:"scheduling-algorithm" yaml:"scheduling-algorithm"` //调度算法
FailLimit int `mapstructure:"fail-limit" json:"fail-limit" yaml:"fail-limit"` //已发现服务最大失败数
RetryTime int `mapstructure:"retry-time" json:"retry-time" yaml:"retry-time"` //重试时间间隔 秒
}
type GrpcServerCfg ¶
type GrpcServerCfg struct {
Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` //启用Grpc服务
Name string `mapstructure:"name" json:"name" yaml:"name"` //服务名,不设置默认为ServerName+"_grpc"
Host string `mapstructure:"host" json:"host" yaml:"host"` //启动host
Port int `mapstructure:"port" json:"port" yaml:"port"` //端口
}
func (*GrpcServerCfg) GetHost ¶
func (e *GrpcServerCfg) GetHost() string
func (*GrpcServerCfg) GetPort ¶
func (e *GrpcServerCfg) GetPort() int
type JWT ¶
type JWT struct {
SignKey string `mapstructure:"sign-key" json:"sign-key" yaml:"sign-key"` // jwt签名
Expires int `mapstructure:"expires" json:"expires" yaml:"expires"` // 有效时长 分钟
Refresh int `mapstructure:"refresh" json:"refresh" yaml:"refresh"` // 刷新时长
Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"` // 签发人
Subject string `mapstructure:"subject" json:"subject" yaml:"subject"` // 签发主体
}
type LogCfg ¶
type LogCfg struct {
Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀
Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出
Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹
MaxAge int `mapstructure:"max-age" json:"max-age" yaml:"max-age"` // 日志留存时间 天
MaxSize int `mapstructure:"max-size" json:"max-size" yaml:"max-size"` // 日志文件大小
MaxBackups int `mapstructure:"max-backups" json:"max-backups" yaml:"max-backups"` // 日志备份天数
LogInConsole bool `mapstructure:"log-in-console" json:"log-in-console" yaml:"log-in-console"` // 输出控制台
EncodeLevel string `mapstructure:"encode-level" json:"encode-level" yaml:"encode-level"` // 编码级
}
func (*LogCfg) GetMaxBackups ¶
func (*LogCfg) GetMaxSize ¶
type RegisterNode ¶
type RegisterNode struct {
Namespace string `mapstructure:"namespace" json:"namespace" yaml:"namespace"` //命名空间
Id string `mapstructure:"id" json:"id" yaml:"id"` //服务id
Name string `mapstructure:"name" json:"name" yaml:"name"` //服务名
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` //服务地址
Port int `mapstructure:"port" json:"port" yaml:"port"` //端口
Protocol string `mapstructure:"protocol" json:"protocol" yaml:"protocol"` //协议
Weight int `mapstructure:"weight" json:"weight" yaml:"weight"` //权重
Interval time.Duration `mapstructure:"interval" json:"interval" yaml:"interval"` //检测间隔
Timeout time.Duration `mapstructure:"timeout" json:"timeout" yaml:"timeout"` //服务检测超时时间
HealthCheck string `mapstructure:"health-check" json:"health-check" yaml:"health-check"` //健康检查地址
Tags []string `mapstructure:"tags" json:"tags" yaml:"tags"` //标签
FailLimit int `mapstructure:"fail-limit" json:"fail-limit" yaml:"fail-limit"` //失败次数限制,到达失败次数就会被禁用
}
type RemoteCfg ¶
type RemoteCfg struct {
Provider string `mapstructure:"provider" json:"provider" yaml:"provider"` //提供方
Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"` //端点
Path string `mapstructure:"path" json:"path" yaml:"path"` //路径
SecretKeyring string `mapstructure:"secret-keyring" json:"secret-keyring" yaml:"secret-keyring"` //安全
ConfigType string `mapstructure:"config-type" json:"config-type" yaml:"config-type"` //配置类型
}
func (*RemoteCfg) GetConfigType ¶
type ServerCfg ¶
type ServerCfg struct {
Name string `mapstructure:"name" json:"name" yaml:"name"` //appname
RemoteEnable bool `mapstructure:"remote-enable" json:"remote-enable" yaml:"remote-enable"` //是否开启远程配置
Mode string `mapstructure:"mode" json:"mode" yaml:"mode"` //模式
Host string `mapstructure:"host" json:"host" yaml:"host"` //启动host
Port int `mapstructure:"port" json:"port" yaml:"port"` //端口
ReadTimeout int `mapstructure:"read-timeout" json:"read-timeout" yaml:"read-timeout"` //读超时 单位秒
WriteTimeout int `mapstructure:"write-timeout" json:"write-timeout" yaml:"write-timeout"` //写超时 单位秒
FSType string `mapstructure:"fs-type" json:"fs-type" yaml:"fs-type"` //文件系统
I18n bool `mapstructure:"i18n" json:"i18n" yaml:"i18n"` //是否开启多语言
Lang string `mapstructure:"lang" json:"lang" yaml:"lang"` //默认语言
CloseWait int `mapstructure:"close-wait" json:"close-wait" yaml:"close-wait"` //服务关闭等待 秒
}
func (*ServerCfg) GetCloseWait ¶
func (*ServerCfg) GetReadTimeout ¶
func (*ServerCfg) GetWriteTimeout ¶
Click to show internal directories.
Click to hide internal directories.