-
Notifications
You must be signed in to change notification settings - Fork 152
/
sdkconfig.go
45 lines (37 loc) · 1.02 KB
/
sdkconfig.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 dlp sdkconfig.go implement config related API
package dlp
import (
"github.com/bytedance/godlp/conf"
)
// public func
// ApplyConfig by configuration content
// 传入conf string 进行配置
func (I *Engine) ApplyConfig(confString string) error {
defer I.recoveryImpl()
if confObj, err := conf.NewDlpConf(confString); err == nil {
return I.applyConfigImpl(confObj)
} else {
return err
}
}
// ApplyConfigFile by config file path
// 传入filePath 进行配置
func (I *Engine) ApplyConfigFile(filePath string) error {
defer I.recoveryImpl()
var retErr error
if confObj, err := conf.NewDlpConfByPath(filePath); err == nil {
retErr = I.applyConfigImpl(confObj)
} else {
retErr = err
}
return retErr
}
func (I *Engine) ApplyConfigDefault() error {
return I.loadDefCfg()
}
// private func
// applyConfigImpl sets confObj into Engine, then postLoadConfig(), such as load Detector and MaskWorker
func (I *Engine) applyConfigImpl(confObj *conf.DlpConf) error {
I.confObj = confObj
return I.postLoadConfig()
}