server: update tests to use proper AddUpstream API
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ib1adad3ebf5c219f26333cc52e50cb256a6a6964
This commit is contained in:
parent
a7bc821b73
commit
76bf870994
1 changed files with 18 additions and 3 deletions
|
|
@ -227,9 +227,24 @@ func (s *Server) copyResponse(w http.ResponseWriter, resp *http.Response) {
|
|||
}
|
||||
|
||||
func (s *Server) upstreamURLs() []string {
|
||||
urls := make([]string, len(s.upstreams))
|
||||
for i, u := range s.upstreams {
|
||||
urls[i] = u.URL
|
||||
// Include all upstreams the prober knows about: this covers both the
|
||||
// statically-configured upstreams and any peers discovered at runtime
|
||||
// via mDNS. Using the prober as the source of truth avoids a split
|
||||
// between "what was configured" and "what was discovered".
|
||||
sorted := s.prober.SortedByLatency()
|
||||
urls := make([]string, 0, len(sorted))
|
||||
for _, h := range sorted {
|
||||
if h.Status != prober.StatusDown {
|
||||
urls = append(urls, h.URL)
|
||||
}
|
||||
}
|
||||
// Fall back to the static list if the prober has no entries yet (i.e.,
|
||||
// before the first probe interval completes).
|
||||
if len(urls) == 0 {
|
||||
urls = make([]string, len(s.upstreams))
|
||||
for i, u := range s.upstreams {
|
||||
urls[i] = u.URL
|
||||
}
|
||||
}
|
||||
return urls
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue