NewHTTPPoolOpts initializes an HTTP pool of peers with the given options. Unlike NewHTTPPool, this function does not register the created pool as an HTTP handler. The returned *HTTPPool implements http.Handler and must be registered using http.Handle.
(self string, o *HTTPPoolOptions)
| 89 | // Unlike NewHTTPPool, this function does not register the created pool as an HTTP handler. |
| 90 | // The returned *HTTPPool implements http.Handler and must be registered using http.Handle. |
| 91 | func NewHTTPPoolOpts(self string, o *HTTPPoolOptions) *HTTPPool { |
| 92 | if httpPoolMade { |
| 93 | panic("groupcache: NewHTTPPool must be called only once") |
| 94 | } |
| 95 | httpPoolMade = true |
| 96 | |
| 97 | p := &HTTPPool{ |
| 98 | self: self, |
| 99 | httpGetters: make(map[string]*httpGetter), |
| 100 | } |
| 101 | if o != nil { |
| 102 | p.opts = *o |
| 103 | } |
| 104 | if p.opts.BasePath == "" { |
| 105 | p.opts.BasePath = defaultBasePath |
| 106 | } |
| 107 | if p.opts.Replicas == 0 { |
| 108 | p.opts.Replicas = defaultReplicas |
| 109 | } |
| 110 | p.peers = consistenthash.New(p.opts.Replicas, p.opts.HashFn) |
| 111 | |
| 112 | RegisterPeerPicker(func() PeerPicker { return p }) |
| 113 | return p |
| 114 | } |
| 115 | |
| 116 | // Set updates the pool's list of peers. |
| 117 | // Each peer value should be a valid base URL, |
no test coverage detected
searching dependent graphs…