1 Star 0 Fork 0

sun/common_pkg

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
option.go 973 Bytes
一键复制 编辑 原始数据 按行查看 历史
yzsunjianguo 提交于 2023-09-19 21:35 +08:00 . init
package goredis
import "time"
// Option set the redis options.
type Option func(*options)
type options struct {
enableTrace bool
dialTimeout time.Duration
readTimeout time.Duration
writeTimeout time.Duration
}
func (o *options) apply(opts ...Option) {
for _, opt := range opts {
opt(o)
}
}
// default settings
func defaultOptions() *options {
return &options{
enableTrace: false, // whether to enable trace, default off
}
}
// WithEnableTrace use trace
func WithEnableTrace() Option {
return func(o *options) {
o.enableTrace = true
}
}
// WithDialTimeout set dail timeout
func WithDialTimeout(t time.Duration) Option {
return func(o *options) {
o.dialTimeout = t
}
}
// WithReadTimeout set read timeout
func WithReadTimeout(t time.Duration) Option {
return func(o *options) {
o.readTimeout = t
}
}
// WithWriteTimeout set write timeout
func WithWriteTimeout(t time.Duration) Option {
return func(o *options) {
o.writeTimeout = t
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jianguosun_admin/common_pkg.git
git@gitee.com:jianguosun_admin/common_pkg.git
jianguosun_admin
common_pkg
common_pkg
v1.0.4

搜索帮助