Feature: make every provider support health check

This commit is contained in:
Dreamacro
2019-12-26 18:41:06 +08:00
parent 3435c67e68
commit af40048841
4 changed files with 70 additions and 85 deletions

View File

@ -55,7 +55,8 @@ func ParseProxyGroup(config map[string]interface{}, proxyMap map[string]C.Proxy,
// if Use not empty, drop health check options
if len(groupOption.Use) != 0 {
pd, err := provider.NewCompatibleProvier(groupName, ps, nil)
hc := provider.NewHealthCheck(ps, "", 0)
pd, err := provider.NewCompatibleProvier(groupName, ps, hc)
if err != nil {
return nil, err
}
@ -64,7 +65,8 @@ func ParseProxyGroup(config map[string]interface{}, proxyMap map[string]C.Proxy,
} else {
// select don't need health check
if groupOption.Type == "select" {
pd, err := provider.NewCompatibleProvier(groupName, ps, nil)
hc := provider.NewHealthCheck(ps, "", 0)
pd, err := provider.NewCompatibleProvier(groupName, ps, hc)
if err != nil {
return nil, err
}
@ -76,11 +78,8 @@ func ParseProxyGroup(config map[string]interface{}, proxyMap map[string]C.Proxy,
return nil, errMissHealthCheck
}
healthOption := &provider.HealthCheckOption{
URL: groupOption.URL,
Interval: uint(groupOption.Interval),
}
pd, err := provider.NewCompatibleProvier(groupName, ps, healthOption)
hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.Interval))
pd, err := provider.NewCompatibleProvier(groupName, ps, hc)
if err != nil {
return nil, err
}