MCPcopy
hub / github.com/CodisLabs/codis / reload

Method reload

cmd/fe/main.go:295–314  ·  view source on GitHub ↗
(d time.Duration)

Source from the content-addressed store, hash-verified

293}
294
295func (r *ReverseProxy) reload(d time.Duration) {
296 if time.Now().Sub(r.loadAt) < d {
297 return
298 }
299 r.routes = make(map[string]*httputil.ReverseProxy)
300 if m, err := r.loader.Reload(); err != nil {
301 log.WarnErrorf(err, "reload reverse proxy failed")
302 } else {
303 for name, host := range m {
304 if name == "" || host == "" {
305 continue
306 }
307 u := &url.URL{Scheme: "http", Host: host}
308 p := httputil.NewSingleHostReverseProxy(u)
309 p.Transport = roundTripper
310 r.routes[name] = p
311 }
312 }
313 r.loadAt = time.Now()
314}
315
316func (r *ReverseProxy) GetProxy(name string) *httputil.ReverseProxy {
317 r.Lock()

Callers 1

GetNamesMethod · 0.95

Calls 3

SubMethod · 0.80
WarnErrorfMethod · 0.80
ReloadMethod · 0.65

Tested by

no test coverage detected