Documentation
¶
Index ¶
- Variables
- func AppendConfigFromAbsPath(fileName string)
- func AppendConfigFromRelativePath(fileName string)
- func AppendFile(filePath string)
- func AppendJsonFile(filePath string)
- func AppendPropertyFile(filePath string)
- func AppendValue(propertiesNewValue string)
- func AppendYamlFile(filePath string)
- func ExistConfigFile() bool
- func GetConfigDeepValues(c *gin.Context)
- func GetConfigValue(c *gin.Context)
- func GetConfigValues(c *gin.Context)
- func GetValue(key string) any
- func GetValueArray(key string) []any
- func GetValueArrayInt(key string) []int
- func GetValueBool(key string) bool
- func GetValueBoolDefault(key string, defaultValue bool) bool
- func GetValueFloat32(key string) float32
- func GetValueFloat32Default(key string, defaultValue float32) float32
- func GetValueFloat64(key string) float64
- func GetValueFloat64Default(key string, defaultValue float64) float64
- func GetValueInt(key string) int
- func GetValueInt16(key string) int16
- func GetValueInt16Default(key string, defaultValue int16) int16
- func GetValueInt32(key string) int32
- func GetValueInt32Default(key string, defaultValue int32) int32
- func GetValueInt64(key string) int64
- func GetValueInt64Default(key string, defaultValue int64) int64
- func GetValueInt8(key string) int8
- func GetValueInt8Default(key string, defaultValue int8) int8
- func GetValueIntDefault(key string, defaultValue int) int
- func GetValueObject(key string, targetPtrObj any) error
- func GetValueString(key string) string
- func GetValueStringDefault(key, defaultValue string) string
- func GetValueUInt(key string) uint
- func GetValueUInt16(key string) uint16
- func GetValueUInt16Default(key string, defaultValue uint16) uint16
- func GetValueUInt32(key string) uint32
- func GetValueUInt32Default(key string, defaultValue uint32) uint32
- func GetValueUInt64(key string) uint64
- func GetValueUInt64Default(key string, defaultValue uint64) uint64
- func GetValueUInt8(key string) uint8
- func GetValueUInt8Default(key string, defaultValue uint8) uint8
- func GetValueUIntDefault(key string, defaultValue uint) uint
- func LoadConfig()
- func LoadConfigFromAbsPath(resourceAbsPath string)
- func LoadConfigFromRelativePath(resourceAbsPath string)
- func LoadFile(filePath string)
- func LoadJsonFile(filePath string)
- func LoadPropertyFile(filePath string)
- func LoadSpringConfig(AConfig any)
- func LoadYamlConfig(fileName string, AConfig any, handler func(data []byte, AConfig any) error) error
- func LoadYamlConfigByAbsolutPath(path string, AConfig any, handler func(data []byte, AConfig any) error) error
- func LoadYamlFile(filePath string)
- func SetValue(key string, value any)
- func UpdateConfig(c *gin.Context)
- type ApplicationProperty
- type BaseApi
- type BaseApplication
- type BaseConfig
- type BaseEndPoint
- type BaseException
- type BaseGin
- type BaseLogger
- type BaseProfile
- type BaseServer
- type DatasourceConfig
- type EmqxConfig
- type EmqxServer
- type EmqxServerUser
- type EndPointConfig
- type EndPointHealth
- type EnvProperty
- type EtcdConfig
- type ExceptionPrint
- type LoggerColor
- type LoggerConfig
- type LoggerSplit
- type LoggerTime
- type RedisClusterConfig
- type RedisConfig
- type RedisSentinelConfig
- type RedisStandaloneConfig
- type StorageConnectionConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ApiModule string
View Source
var CurrentProfile = ""
Functions ¶
func AppendConfigFromAbsPath ¶ added in v0.3.0
func AppendConfigFromAbsPath(fileName string)
func AppendConfigFromRelativePath ¶ added in v0.3.0
func AppendConfigFromRelativePath(fileName string)
func AppendFile ¶ added in v1.1.1
func AppendFile(filePath string)
func AppendJsonFile ¶ added in v0.3.0
func AppendJsonFile(filePath string)
func AppendPropertyFile ¶ added in v0.3.0
func AppendPropertyFile(filePath string)
func AppendValue ¶ added in v1.1.1
func AppendValue(propertiesNewValue string)
func AppendYamlFile ¶ added in v0.3.0
func AppendYamlFile(filePath string)
func ExistConfigFile ¶ added in v1.0.0
func ExistConfigFile() bool
func GetConfigDeepValues ¶ added in v1.3.0
func GetConfigValue ¶ added in v0.3.0
func GetConfigValues ¶ added in v0.3.0
func GetValueArray ¶ added in v1.0.0
func GetValueArrayInt ¶ added in v1.0.0
func GetValueBool ¶ added in v0.3.0
func GetValueBoolDefault ¶ added in v0.3.0
func GetValueFloat32 ¶ added in v0.3.0
func GetValueFloat32Default ¶ added in v0.3.0
func GetValueFloat64 ¶ added in v0.3.0
func GetValueFloat64Default ¶ added in v0.3.0
func GetValueInt ¶ added in v0.3.0
func GetValueInt16 ¶ added in v0.3.0
func GetValueInt16Default ¶ added in v0.3.0
func GetValueInt32 ¶ added in v0.3.0
func GetValueInt32Default ¶ added in v0.3.0
func GetValueInt64 ¶ added in v0.3.0
func GetValueInt64Default ¶ added in v0.3.0
func GetValueInt8 ¶ added in v0.3.0
func GetValueInt8Default ¶ added in v0.3.0
func GetValueIntDefault ¶ added in v0.3.0
func GetValueObject ¶ added in v0.3.0
func GetValueString ¶ added in v0.3.0
func GetValueStringDefault ¶ added in v0.3.0
func GetValueUInt ¶ added in v0.3.0
func GetValueUInt16 ¶ added in v0.3.0
func GetValueUInt16Default ¶ added in v0.3.0
func GetValueUInt32 ¶ added in v0.3.0
func GetValueUInt32Default ¶ added in v0.3.0
func GetValueUInt64 ¶ added in v0.3.0
func GetValueUInt64Default ¶ added in v0.3.0
func GetValueUInt8 ¶ added in v0.3.0
func GetValueUInt8Default ¶ added in v0.3.0
func GetValueUIntDefault ¶ added in v0.3.0
func LoadConfig ¶
func LoadConfig()
func LoadConfigFromAbsPath ¶ added in v0.3.0
func LoadConfigFromAbsPath(resourceAbsPath string)
func LoadConfigFromRelativePath ¶ added in v0.3.0
func LoadConfigFromRelativePath(resourceAbsPath string)
func LoadJsonFile ¶ added in v0.3.0
func LoadJsonFile(filePath string)
func LoadPropertyFile ¶ added in v0.3.0
func LoadPropertyFile(filePath string)
func LoadSpringConfig ¶ added in v0.3.0
func LoadSpringConfig(AConfig any)
func LoadYamlConfig ¶ added in v0.3.0
func LoadYamlConfig(fileName string, AConfig any, handler func(data []byte, AConfig any) error) error
LoadYamlConfig read fileName from private path fileName,eg:application.yml, and transform it to AConfig note: AConfig must be a pointer
func LoadYamlConfigByAbsolutPath ¶ added in v0.3.0
func LoadYamlConfigByAbsolutPath(path string, AConfig any, handler func(data []byte, AConfig any) error) error
LoadYamlConfigByAbsolutPath read fileName from absolute path fileName,eg:/home/isc-gobase/application.yml, and transform it to AConfig note: AConfig must be a pointer
func LoadYamlFile ¶ added in v0.3.0
func LoadYamlFile(filePath string)
func UpdateConfig ¶ added in v0.3.0
Types ¶
type ApplicationProperty ¶ added in v0.3.0
type BaseApplication ¶ added in v1.0.0
type BaseApplication struct {
Name string `yaml:"name"` // 应用名字
}
type BaseConfig ¶ added in v0.3.0
type BaseConfig struct { Api BaseApi `yaml:"api"` Application BaseApplication `yaml:"application"` Server BaseServer `yaml:"server"` EndPoint BaseEndPoint `yaml:"endpoint"` Logger BaseLogger `yaml:"logger"` Profiles BaseProfile `yaml:"profiles"` }
BaseConfig base前缀
var BaseCfg BaseConfig
type BaseEndPoint ¶ added in v1.0.0
type BaseEndPoint struct { Health EndPointHealth `yaml:"health"` // 健康检查[端点] Config EndPointConfig `yaml:"config"` // 配置管理[端点] }
type BaseException ¶ added in v1.0.0
type BaseException struct {
Print ExceptionPrint `yaml:"print"` // 异常返回打印
}
type BaseGin ¶ added in v1.0.0
type BaseGin struct {
Mode string `yaml:"mode"` // 有三种模式:debug/release/test
}
type BaseLogger ¶ added in v1.0.0
type BaseLogger struct { Level string // 日志root级别:trace/debug/info/warn/error/fatal/panic,默认:info Path string Time LoggerTime // 时间配置 Color LoggerColor // 日志颜色 Split LoggerSplit // 日志切分 Dir string Max struct { History int } Console struct { WriteFile bool } }
type BaseProfile ¶ added in v1.0.0
type BaseProfile struct {
Active string `yaml:"active"`
}
type BaseServer ¶ added in v1.0.0
type BaseServer struct { Enable bool `yaml:"enable"` // 是否启用 Port int `yaml:"port"` // 端口号 Gin BaseGin `yaml:"gin"` // web框架gin的配置 Exception BaseException `yaml:"exception"` // 异常处理 }
type DatasourceConfig ¶ added in v1.4.5
type DatasourceConfig struct { Username string Password string Host string Port int DriverName string DbName string SqlitePath string }
---------------------------- base.datasource ----------------------------
type EmqxConfig ¶ added in v1.5.2
type EmqxConfig struct { Servers []string ClientId string Username string Password string CleanSession bool Order bool WillEnabled bool WillTopic string WillQos byte WillRetained bool ProtocolVersion uint KeepAlive int64 PingTimeout string ConnectTimeout string MaxReconnectInterval string AutoReconnect bool ConnectRetryInterval string ConnectRetry bool WriteTimeout string ResumeSubs bool MaxResumePubInFlight int AutoAckDisabled bool }
var EmqxCfg EmqxConfig
type EmqxServer ¶ added in v1.5.2
type EmqxServer struct { User *EmqxServerUser // username and password information Host string // host or host:port }
type EmqxServerUser ¶ added in v1.5.2
type EndPointConfig ¶ added in v1.0.0
type EndPointConfig struct {
Enable bool `yaml:"enable"` // 是否启用
}
type EndPointHealth ¶ added in v1.0.0
type EndPointHealth struct {
Enable bool `yaml:"enable"` // 是否启用
}
type EnvProperty ¶ added in v0.3.0
type EtcdConfig ¶ added in v1.4.5
type EtcdConfig struct { // etcd的服务ip:port列表 Endpoints []string Username string Password string // 自动同步间隔:是用其最新成员更新端点的间隔;默认为0,即禁用自动同步;配置示例:1s、1000ms AutoSyncInterval string // 拨号超时:是指连接失败后的超时时间;配置示例:1s、1000ms DialTimeout string // 拨号保持连接时间:是客户端ping服务器以查看传输是否连接的时间;配置示例:1s、1000ms DialKeepAliveTime string // 拨号保持连接超时:是客户端等待响应保持连接探测的时间,如果在此时间内没有收到响应,则连接将被关闭;配置示例:1s、1000ms DialKeepAliveTimeout string // 拨号重试策略: 默认为空:表示默认不重试;1、2、3...表示重试多少次;always:表示一直重试 DialRetry string // 最大呼叫:发送MSG大小是客户端请求发送的字节限制 MaxCallSendMsgSize int // 最大调用recv MSG大小是客户端响应接收限制 MaxCallRecvMsgSize int // 当设置拒绝旧集群时,将拒绝在过时的集群上创建客户端 RejectOldCluster bool // 设置允许无流时将允许客户端发送keepalive ping到服务器没有任何活动流rp cs PermitWithoutStream bool }
var EtcdCfg EtcdConfig
type ExceptionPrint ¶ added in v1.0.0
type LoggerColor ¶ added in v1.0.0
type LoggerColor struct {
Enable bool `yaml:"enable"` // 是否启用
}
type LoggerConfig ¶ added in v0.3.0
type LoggerConfig struct { Level string `yaml:"level"` Path string `yaml:"level"` Time struct { Format string `yaml:"format"` } `yaml:"time"` Color struct { Enable bool `yaml:"enable"` } `yaml:"color"` Split struct { Enable bool `yaml:"enable"` Size int64 `yaml:"size"` } `yaml:"split"` Dir string `yaml:"dir"` Max struct { History int `yaml:"history"` } `yaml:"max"` Console struct { WriteFile bool `yaml:"writeFile"` } `yaml:"console"` }
type LoggerSplit ¶ added in v1.0.0
type LoggerTime ¶ added in v1.0.0
type LoggerTime struct {
Format string `yaml:"format"` // 时间格式,time包中的内容,比如:time.RFC3339
}
type RedisClusterConfig ¶ added in v1.0.12
type RedisConfig ¶ added in v1.0.12
type RedisConfig struct { Password string Username string // 单节点 Standalone RedisStandaloneConfig // 哨兵 Sentinel RedisSentinelConfig // 集群 Cluster RedisClusterConfig // ----- 命令执行失败配置 ----- // 命令执行失败时候,最大重试次数,默认3次,-1(不是0)则不重试 MaxRetries int // (单位毫秒) 命令执行失败时候,每次重试的最小回退时间,默认8毫秒,-1则禁止回退 MinRetryBackoff int // (单位毫秒)命令执行失败时候,每次重试的最大回退时间,默认512毫秒,-1则禁止回退 MaxRetryBackoff int // ----- 超时配置 ----- // (单位毫秒)超时:创建新链接的拨号超时时间,默认15秒 DialTimeout int // (单位毫秒)超时:读超时,默认3秒,使用-1,使用-1则表示无超时,0的话是表示默认3秒 ReadTimeout int // (单位毫秒)超时:写超时,默认是读超时3秒,使用-1,使用-1则表示无超时,0的话是表示默认3秒 WriteTimeout int // ----- 连接池相关配置 ----- // 连接池类型:fifo:true;lifo:false;和lifo相比,fifo开销更高 PoolFIFO bool // 最大连接池大小:默认每个cpu核是10个连接,cpu核数可以根据函数runtime.GOMAXPROCS来配置,默认是runtime.NumCpu PoolSize int // 最小空闲连接数 MinIdleConns int // (单位毫秒) 连接存活时长,默认不关闭 MaxConnAge int // (单位毫秒)获取链接池中的链接都在忙,则等待对应的时间,默认读超时+1秒 PoolTimeout int // (单位毫秒)空闲链接时间,超时则关闭,注意:该时间要小于服务端的超时时间,否则会出现拿到的链接失效问题,默认5分钟,-1表示禁用超时检查 IdleTimeout int // (单位毫秒)空闲链接核查频率,默认1分钟。-1禁止空闲链接核查,即使配置了IdleTime也不行 IdleCheckFrequency int }
RedisConfig base.redis前缀
var RedisCfg RedisConfig
type RedisSentinelConfig ¶ added in v1.0.12
type RedisSentinelConfig struct { // 哨兵的集群名字 Master string // 哨兵节点地址 Addrs []string // 数据库节点 Database int // 哨兵用户 SentinelUser string // 哨兵密码 SentinelPassword string // 将所有命令路由到从属只读节点。 SlaveOnly bool }
RedisSentinelConfig base.redis.sentinel
Click to show internal directories.
Click to hide internal directories.