From c4d27a6302b303a3debe0303fb197f044204fc0b Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Fri, 2 Aug 2024 19:01:02 +0545 Subject: [PATCH] feat: mongo health --- pkg/health/health_mongo.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pkg/health/health_mongo.go diff --git a/pkg/health/health_mongo.go b/pkg/health/health_mongo.go new file mode 100644 index 0000000..c3a6f30 --- /dev/null +++ b/pkg/health/health_mongo.go @@ -0,0 +1,18 @@ +package health + +func GetMongoHealth(obj map[string]any) (health HealthStatus) { + hr := HealthStatus{ + Status: HealthStatusUnknown, + Health: HealthUnknown, + Ready: false, + } + + if v, ok := obj["clusterType"]; ok && v.(string) == "REPLICASET" { + if v, ok := obj["stateName"]; ok { + hr.Status = HealthStatusCode(v.(string)) + hr.Ready = true + } + } + + return hr +}