-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmanager.go
45 lines (35 loc) · 864 Bytes
/
manager.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
package sensitive
import (
"github.com/sgoware/go-sensitive/filter"
"github.com/sgoware/go-sensitive/store"
)
type Manager struct {
store.Store
filter.Filter
}
func NewFilter(storeOption StoreOption, filterOption FilterOption) *Manager {
var filterStore store.Store
var myFilter filter.Filter
switch storeOption.Type {
case StoreMemory:
filterStore = store.NewMemoryModel()
default:
panic("invalid store type")
}
switch filterOption.Type {
case FilterDfa:
dfaModel := filter.NewDfaModel()
go dfaModel.Listen(filterStore.GetAddChan(), filterStore.GetDelChan())
myFilter = dfaModel
case FilterAc:
acModel := filter.NewAcModel()
go acModel.Listen(filterStore.GetAddChan(), filterStore.GetDelChan())
myFilter = acModel
default:
panic("invalid filter type")
}
return &Manager{
Store: filterStore,
Filter: myFilter,
}
}