dataRT/config/redis.go

148 lines
2.9 KiB
Go

package config
type redisConfig struct {
Addr string `json:"addr" yaml:"addr"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
DB int `json:"db" yaml:"db"`
RESP int `json:"resp" yaml:"resp"`
DialTimeout int `json:"dialtimeout" yaml:"dialtimeout"`
ReadTimeout int `json:"readtimeout" yaml:"readtimeout"`
WriteTimeout int `json:"writetimeout" yaml:"writetimeout"`
PoolSize int `json:"poolsize" yaml:"poolsize"`
}
func NewRedisConfig() *redisConfig {
return new(redisConfig)
}
func (conf *redisConfig) GetAddr() string {
if conf == nil {
panic("redis config is nil")
}
return conf.Addr
}
func (conf *redisConfig) SetAddr(addr string) {
if conf == nil {
panic("redis config is nil")
}
conf.Addr = addr
}
func (conf *redisConfig) GetUsername() string {
if conf == nil {
panic("redis config is nil")
}
return conf.Username
}
func (conf *redisConfig) SetUsername(username string) {
if conf == nil {
panic("redis config is nil")
}
conf.Username = username
}
func (conf *redisConfig) GetPassword() string {
if conf == nil {
panic("redis config is nil")
}
return conf.Password
}
func (conf *redisConfig) SetPassword(password string) {
if conf == nil {
panic("redis config is nil")
}
conf.Password = password
}
func (conf *redisConfig) GetDB() int {
if conf == nil {
panic("redis config is nil")
}
return conf.DB
}
func (conf *redisConfig) SetDB(db int) {
if conf == nil {
panic("redis config is nil")
}
conf.DB = db
}
func (conf *redisConfig) GetRESP() int {
if conf == nil {
panic("redis config is nil")
}
return conf.RESP
}
func (conf *redisConfig) SetRESP(resp int) {
if conf == nil {
panic("redis config is nil")
}
conf.RESP = resp
}
func (conf *redisConfig) GetDialTimeout() int {
if conf == nil {
panic("redis config is nil")
}
return conf.DialTimeout
}
func (conf *redisConfig) SetDialTimeout(dialTimeout int) {
if conf == nil {
panic("redis config is nil")
}
conf.DialTimeout = dialTimeout
}
func (conf *redisConfig) GetReadTimeout() int {
if conf == nil {
panic("redis config is nil")
}
return conf.ReadTimeout
}
func (conf *redisConfig) SetReadTimeout(readTimeout int) {
if conf == nil {
panic("redis config is nil")
}
conf.ReadTimeout = readTimeout
}
func (conf *redisConfig) GetWriteTimeout() int {
if conf == nil {
panic("redis config is nil")
}
return conf.WriteTimeout
}
func (conf *redisConfig) SetWriteTimeout(writeTimeout int) {
if conf == nil {
panic("redis config is nil")
}
conf.WriteTimeout = writeTimeout
}
func (conf *redisConfig) GetPoolSize() int {
if conf == nil {
panic("redis config is nil")
}
return conf.PoolSize
}
func (conf *redisConfig) SetPoolSIze(poolSize int) {
if conf == nil {
panic("redis config is nil")
}
conf.PoolSize = poolSize
}
func redisConfigName() string {
return "redis.json"
}