1 Star 0 Fork 0

mosache / go-zero

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
conf.go 804 Bytes
一键复制 编辑 原始数据 按行查看 历史
kevwan 提交于 2020-07-26 17:09 . initial import
package redis
import "errors"
var (
ErrEmptyHost = errors.New("empty redis host")
ErrEmptyType = errors.New("empty redis type")
ErrEmptyKey = errors.New("empty redis key")
)
type (
RedisConf struct {
Host string
Type string `json:",default=node,options=node|cluster"`
Pass string `json:",optional"`
}
RedisKeyConf struct {
RedisConf
Key string `json:",optional"`
}
)
func (rc RedisConf) NewRedis() *Redis {
return NewRedis(rc.Host, rc.Type, rc.Pass)
}
func (rc RedisConf) Validate() error {
if len(rc.Host) == 0 {
return ErrEmptyHost
}
if len(rc.Type) == 0 {
return ErrEmptyType
}
return nil
}
func (rkc RedisKeyConf) Validate() error {
if err := rkc.RedisConf.Validate(); err != nil {
return err
}
if len(rkc.Key) == 0 {
return ErrEmptyKey
}
return nil
}
1
https://gitee.com/mosache/go-zero.git
git@gitee.com:mosache/go-zero.git
mosache
go-zero
go-zero
dfb45c801a6c

搜索帮助

53164aa7 5694891 3bd8fe86 5694891