perf: optimize alert plugin call(#886) (#891)

This commit is contained in:
Jeyrce.Lu 2022-03-22 18:10:35 +08:00 committed by GitHub
parent 3b9e40c5d4
commit 18164fdb16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -409,13 +409,15 @@ type Notifier interface {
// call notify.so via golang plugin build // call notify.so via golang plugin build
// ig. etc/script/notify/notify.so // ig. etc/script/notify/notify.so
func alertingCallPlugin(stdinBytes []byte) { func alertingCallPlugin(stdinBytes []byte) {
if !config.C.Alerting.CallPlugin.Enable {
return
}
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
logger.Errorf("call notify plugin on unsupported os: %s", runtime.GOOS) logger.Errorf("call notify plugin on unsupported os: %s", runtime.GOOS)
return return
} }
if !config.C.Alerting.CallPlugin.Enable {
return
}
p, err := plugin.Open(config.C.Alerting.CallPlugin.PluginPath) p, err := plugin.Open(config.C.Alerting.CallPlugin.PluginPath)
if err != nil { if err != nil {
logger.Errorf("failed to open notify plugin: %v", err) logger.Errorf("failed to open notify plugin: %v", err)