Codebase list golang-github-go-kit-kit / 792a2f2
Loadbalancer: satisfy Publisher interface with EndpointCache Cihangir SAVAS 8 years ago
3 changed file(s) with 6 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
7171
7272 // Endpoints implements the Publisher interface.
7373 func (p *Publisher) Endpoints() ([]endpoint.Endpoint, error) {
74 return p.cache.Endpoints(), nil
74 return p.cache.Endpoints()
7575 }
7676
7777 var (
7777 t.m = m
7878 }
7979
80 // Endpoints returns the current set of endpoints in undefined order.
81 func (t *EndpointCache) Endpoints() []endpoint.Endpoint {
80 // Endpoints returns the current set of endpoints in undefined order. Satisfies
81 // Publisher interface.
82 func (t *EndpointCache) Endpoints() ([]endpoint.Endpoint, error) {
8283 t.mtx.RLock()
8384 defer t.mtx.RUnlock()
8485 a := make([]endpoint.Endpoint, 0, len(t.m))
8586 for _, ec := range t.m {
8687 a = append(a, ec.Endpoint)
8788 }
88 return a
89 return a, nil
8990 }
6161
6262 // Endpoints implements the Publisher interface.
6363 func (p *Publisher) Endpoints() ([]endpoint.Endpoint, error) {
64 return p.cache.Endpoints(), nil
64 return p.cache.Endpoints()
6565 }
6666
6767 // Stop terminates the Publisher.