Loadbalancer: satisfy Publisher interface with EndpointCache
Cihangir SAVAS
8 years ago
71 | 71 |
|
72 | 72 |
// Endpoints implements the Publisher interface.
|
73 | 73 |
func (p *Publisher) Endpoints() ([]endpoint.Endpoint, error) {
|
74 | |
return p.cache.Endpoints(), nil
|
|
74 |
return p.cache.Endpoints()
|
75 | 75 |
}
|
76 | 76 |
|
77 | 77 |
var (
|
77 | 77 |
t.m = m
|
78 | 78 |
}
|
79 | 79 |
|
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) {
|
82 | 83 |
t.mtx.RLock()
|
83 | 84 |
defer t.mtx.RUnlock()
|
84 | 85 |
a := make([]endpoint.Endpoint, 0, len(t.m))
|
85 | 86 |
for _, ec := range t.m {
|
86 | 87 |
a = append(a, ec.Endpoint)
|
87 | 88 |
}
|
88 | |
return a
|
|
89 |
return a, nil
|
89 | 90 |
}
|
61 | 61 |
|
62 | 62 |
// Endpoints implements the Publisher interface.
|
63 | 63 |
func (p *Publisher) Endpoints() ([]endpoint.Endpoint, error) {
|
64 | |
return p.cache.Endpoints(), nil
|
|
64 |
return p.cache.Endpoints()
|
65 | 65 |
}
|
66 | 66 |
|
67 | 67 |
// Stop terminates the Publisher.
|