Skip to content

Commit

Permalink
chore: get HealCheckURL from pd if groupOption URL is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Larvan2 committed Feb 24, 2024
1 parent d2a5376 commit cb7e8b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 3 additions & 4 deletions adapter/outboundgroup/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,16 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
}

if len(groupOption.Use) != 0 {
if groupOption.URL == "" {
groupOption.URL = C.DefaultTestURL
}
list, err := getProviders(providersMap, groupOption.Use)
if err != nil {
return nil, fmt.Errorf("%s: %w", groupName, err)
}

if groupOption.URL == "" {
groupOption.URL = list[0].HealthCheckURL()
}
// different proxy groups use different test URL
addTestUrlToProviders(list, groupOption.URL, expectedStatus, groupOption.Filter, uint(groupOption.Interval))

providers = append(providers, list...)
} else {
groupOption.Filter = ""
Expand Down
8 changes: 8 additions & 0 deletions adapter/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func (pp *proxySetProvider) Touch() {
pp.healthCheck.touch()
}

func (pp *proxySetProvider) HealthCheckURL() string {
return pp.healthCheck.url
}

func (pp *proxySetProvider) RegisterHealthCheckTask(url string, expectedStatus utils.IntRanges[uint16], filter string, interval uint) {
pp.healthCheck.registerHealthCheckTask(url, expectedStatus, filter, interval)
}
Expand Down Expand Up @@ -271,6 +275,10 @@ func (cp *compatibleProvider) Touch() {
cp.healthCheck.touch()
}

func (cp *compatibleProvider) HealthCheckURL() string {
return cp.healthCheck.url
}

func (cp *compatibleProvider) RegisterHealthCheckTask(url string, expectedStatus utils.IntRanges[uint16], filter string, interval uint) {
cp.healthCheck.registerHealthCheckTask(url, expectedStatus, filter, interval)
}
Expand Down
1 change: 1 addition & 0 deletions constant/provider/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type ProxyProvider interface {
HealthCheck()
Version() uint32
RegisterHealthCheckTask(url string, expectedStatus utils.IntRanges[uint16], filter string, interval uint)
HealthCheckURL() string
}

// RuleProvider interface
Expand Down

0 comments on commit cb7e8b6

Please sign in to comment.