|
|
|
@ -5,7 +5,6 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"reflect"
|
|
|
|
|
"sort"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/go-bexpr"
|
|
|
|
@ -208,18 +207,17 @@ func (noopFilterEvaluator) Evaluate(_ interface{}) (bool, error) {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// cachedHealResultSorter sorts the results to match memdb semantics
|
|
|
|
|
// sortCheckServiceNodes sorts the results to match memdb semantics
|
|
|
|
|
// Sort results by Node.Node, if 2 instances match, order by Service.ID
|
|
|
|
|
// Will allow result to be stable sorted and match queries without cache
|
|
|
|
|
func cachedHealResultSorter(serviceNodes *structs.IndexedCheckServiceNodes) {
|
|
|
|
|
func sortCheckServiceNodes(serviceNodes *structs.IndexedCheckServiceNodes) {
|
|
|
|
|
sort.SliceStable(serviceNodes.Nodes, func(i, j int) bool {
|
|
|
|
|
left := serviceNodes.Nodes[i]
|
|
|
|
|
right := serviceNodes.Nodes[j]
|
|
|
|
|
res := strings.Compare(left.Node.Node, right.Node.Node)
|
|
|
|
|
if res != 0 {
|
|
|
|
|
return res < 0
|
|
|
|
|
if left.Node.Node == right.Node.Node {
|
|
|
|
|
return left.Service.ID < right.Service.ID
|
|
|
|
|
}
|
|
|
|
|
return strings.Compare(left.Service.ID, right.Service.ID) < 0
|
|
|
|
|
return left.Node.Node < right.Node.Node
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -234,7 +232,7 @@ func (s *healthView) Result(index uint64) (interface{}, error) {
|
|
|
|
|
for _, node := range s.state {
|
|
|
|
|
result.Nodes = append(result.Nodes, node)
|
|
|
|
|
}
|
|
|
|
|
cachedHealResultSorter(&result)
|
|
|
|
|
sortCheckServiceNodes(&result)
|
|
|
|
|
|
|
|
|
|
return &result, nil
|
|
|
|
|
}
|
|
|
|
|