-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.go
63 lines (54 loc) · 931 Bytes
/
option.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
52
53
54
55
56
57
58
59
60
61
62
63
package diskqueue
import (
"time"
)
type Option func(*diskQueue)
func WithName(name string) Option {
return func(d *diskQueue) {
if name != "" {
d.name = name
}
}
}
func WithDataPath(dataPath string) Option {
return func(d *diskQueue) {
if dataPath != "" {
d.dataPath = dataPath
}
}
}
func WithMaxBytesPerFile(max int64) Option {
return func(d *diskQueue) {
if max > 0 {
d.maxBytesPerFile = max
}
}
}
func WithMinMsgSize(size int32) Option {
return func(d *diskQueue) {
if size >= 0 {
d.minMsgSize = size
}
}
}
func WithMaxMsgSize(size int32) Option {
return func(d *diskQueue) {
if size > 0 {
d.maxMsgSize = size
}
}
}
func WithSyncEvery(count int64) Option {
return func(d *diskQueue) {
if count > 0 {
d.syncEvery = count
}
}
}
func WithSyncTimeout(timeout time.Duration) Option {
return func(d *diskQueue) {
if timeout > 0 {
d.syncTimeout = timeout
}
}
}