-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
91 lines (74 loc) · 1.59 KB
/
config.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package vfsindex
import "time"
var Opt optionState = optionState{
mergeDuration: 1 * time.Minute,
cleanAfterMergeing: true,
useBsearch: true,
}
type optionState struct {
column string
output Outputer
rootDir string
idxMergeOnSearch bool
cntConcurrent int
mergeDuration time.Duration
customDecoders []Decoder
cleanAfterMergeing bool
useBsearch bool
}
//type ReaderOpt map[string]string
type Option func(*optionState)
// ReaderColumn ... config for columname for search/read
func ReaderColumn(s string) Option {
return func(opt *optionState) {
opt.column = s
}
}
func mergeOpt(s *optionState, opts ...Option) {
for _, opt := range opts {
opt(s)
}
}
// RootDir ... set index top directory
func RootDir(s string) Option {
return func(opt *optionState) {
opt.rootDir = s
}
}
type Outputer byte
const (
JsonOutput = iota
MapInfOutput
)
func Output(t Outputer) Option {
return func(opt *optionState) {
opt.output = t
}
}
// MergeOnSearch ... enable to merge index on search
func MergeOnSearch(enable bool) Option {
return func(opt *optionState) {
opt.idxMergeOnSearch = enable
}
}
func RegitConcurrent(n int) Option {
return func(opt *optionState) {
opt.cntConcurrent = n
}
}
func MergeDuration(d time.Duration) Option {
return func(opt *optionState) {
opt.mergeDuration = d
}
}
func EnableCleanAfterMerge(t bool) Option {
return func(opt *optionState) {
opt.cleanAfterMergeing = t
}
}
func UseBsearch(t bool) Option {
return func(opt *optionState) {
opt.useBsearch = t
Opt.useBsearch = t
}
}