-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.go
51 lines (43 loc) · 964 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package redisgo
import "time"
type Option func(opt options) options
type options struct {
rbuf int
wbuf int
rtimeout time.Duration
wtimeout time.Duration
}
var defaultoptions = options{
rbuf: 2048,
wbuf: 2048,
rtimeout: 30 * time.Second,
wtimeout: 30 * time.Second,
}
// WithReadBuffer set read buffer size of connection
func WithReadBuffer(sz int) Option {
return func(opt options) options {
opt.rbuf = sz
return opt
}
}
// WithWriteBuffer set write buffer size of connection
func WithWriteBuffer(sz int) Option {
return func(opt options) options {
opt.wbuf = sz
return opt
}
}
// WithReadTimeout set read timeout of Conn.Recv
func WithReadTimeout(t time.Duration) Option {
return func(opt options) options {
opt.rtimeout = t
return opt
}
}
// WithWriteTimeout set write timeout of Conn.Send
func WithWriteTimeout(t time.Duration) Option {
return func(opt options) options {
opt.wtimeout = t
return opt
}
}