MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / restartWithNewConfig

Method restartWithNewConfig

proxy.go:768–804  ·  view source on GitHub ↗
(caches map[string]*cache.AsyncCache, clusters map[string]*cluster, users map[string]*user)

Source from the content-addressed store, hash-verified

766}
767
768func (rp *reverseProxy) restartWithNewConfig(caches map[string]*cache.AsyncCache, clusters map[string]*cluster, users map[string]*user) {
769 // Reset metrics from the previous configs, which may become irrelevant
770 // with new configs.
771 // Counters and Summary metrics are always relevant.
772 // Gauge metrics may become irrelevant if they may freeze at non-zero
773 // value after config reload.
774 topology.HostHealth.Reset()
775 cacheSize.Reset()
776 cacheItems.Reset()
777
778 // Start service goroutines with new configs.
779 for _, c := range clusters {
780 for _, r := range c.replicas {
781 for _, h := range r.hosts {
782 rp.reloadWG.Add(1)
783 go func(h *topology.Node) {
784 h.StartHeartbeat(rp.reloadSignal)
785 rp.reloadWG.Done()
786 }(h)
787 }
788 }
789 for _, cu := range c.users {
790 rp.reloadWG.Add(1)
791 go func(cu *clusterUser) {
792 cu.rateLimiter.run(rp.reloadSignal)
793 rp.reloadWG.Done()
794 }(cu)
795 }
796 }
797 for _, u := range users {
798 rp.reloadWG.Add(1)
799 go func(u *user) {
800 u.rateLimiter.run(rp.reloadSignal)
801 rp.reloadWG.Done()
802 }(u)
803 }
804}
805
806// refreshCacheMetrics refreshes cacheSize and cacheItems metrics.
807func (rp *reverseProxy) refreshCacheMetrics() {

Callers 1

applyConfigMethod · 0.95

Calls 2

StartHeartbeatMethod · 0.80
runMethod · 0.80

Tested by

no test coverage detected