more updates

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2020-01-16 16:39:28 +01:00
parent 09f4e8aee4
commit a231daf17f
5 changed files with 142 additions and 58 deletions

View File

@@ -14,7 +14,7 @@ type assignment struct {
version int // not sure what do with and if we should discard all clusters.
}
func (a *assignment) SetClusterLoadAssignment(cluster string, cla *xdspb.ClusterLoadAssignment) {
func (a *assignment) setClusterLoadAssignment(cluster string, cla *xdspb.ClusterLoadAssignment) {
// If cla is nil we just found a cluster, check if we already know about it, or if we need to make a new entry.
a.mu.Lock()
defer a.mu.Unlock()
@@ -30,8 +30,7 @@ func (a *assignment) SetClusterLoadAssignment(cluster string, cla *xdspb.Cluster
}
// ClusterLoadAssignment returns the healthy endpoints and their weight.
func (a *assignment) ClusterLoadAssignment(cluster string) *xdspb.ClusterLoadAssignment {
func (a *assignment) clusterLoadAssignment(cluster string) *xdspb.ClusterLoadAssignment {
a.mu.RLock()
cla, ok := a.cla[cluster]
a.mu.RUnlock()
@@ -41,7 +40,7 @@ func (a *assignment) ClusterLoadAssignment(cluster string) *xdspb.ClusterLoadAss
return cla
}
func (a *assignment) Clusters() []string {
func (a *assignment) clusters() []string {
a.mu.RLock()
defer a.mu.RUnlock()
clusters := make([]string, len(a.cla))
@@ -56,7 +55,7 @@ func (a *assignment) Clusters() []string {
// Select selects a backend from cla, using weighted random selection. It only selects
// backends that are reporting healthy.
func (a *assignment) Select(cluster string) net.IP {
cla := a.ClusterLoadAssignment(cluster)
cla := a.clusterLoadAssignment(cluster)
if cla == nil {
return nil
}