From 4372a5221cab57325db3061419bceda393bbefff Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" Date: Wed, 30 Nov 2022 11:10:03 -0600 Subject: [PATCH] feedback --- .../services/peerstream/subscription_manager.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/agent/grpc-external/services/peerstream/subscription_manager.go b/agent/grpc-external/services/peerstream/subscription_manager.go index 338d0e9caa..e8a4e48b4d 100644 --- a/agent/grpc-external/services/peerstream/subscription_manager.go +++ b/agent/grpc-external/services/peerstream/subscription_manager.go @@ -672,8 +672,11 @@ var statusScores = map[string]int{ api.HealthPassing: 4, } -func isStatusBetter(curr, next string) bool { - return statusScores[next] < statusScores[curr] +func getMostImportantStatus(a, b string) string { + if statusScores[a] < statusScores[b] { + return a + } + return b } func flattenChecks( @@ -696,9 +699,7 @@ func flattenChecks( healthStatus = api.HealthMaint break // always wins } - if isStatusBetter(healthStatus, chk.Status) { - healthStatus = chk.Status - } + healthStatus = getMostImportantStatus(healthStatus, chk.Status) } }