Set updates the pool's list of peers. Each peer value should be a valid base URL, for example "http://example.net:8000".
(peers ...string)
| 117 | // Each peer value should be a valid base URL, |
| 118 | // for example "http://example.net:8000". |
| 119 | func (p *HTTPPool) Set(peers ...string) { |
| 120 | p.mu.Lock() |
| 121 | defer p.mu.Unlock() |
| 122 | p.peers = consistenthash.New(p.opts.Replicas, p.opts.HashFn) |
| 123 | p.peers.Add(peers...) |
| 124 | p.httpGetters = make(map[string]*httpGetter, len(peers)) |
| 125 | for _, peer := range peers { |
| 126 | p.httpGetters[peer] = &httpGetter{transport: p.Transport, baseURL: peer + p.opts.BasePath} |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | func (p *HTTPPool) PickPeer(key string) (ProtoGetter, bool) { |
| 131 | p.mu.Lock() |