From 8e0cfa42136bb189c7aa1622925c240fa6a3d8dd Mon Sep 17 00:00:00 2001 From: smahana123 Date: Thu, 6 Apr 2023 17:06:51 +0530 Subject: [PATCH] Adding health check for the reddis db. Signed-off-by: smahana123 Change-Id: Ifae98b741b28df12679112b32212618030e54720 --- syncstorage.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/syncstorage.go b/syncstorage.go index 349bcc3..66f93a1 100644 --- a/syncstorage.go +++ b/syncstorage.go @@ -26,6 +26,7 @@ import ( "crypto/rand" "encoding/base64" "errors" + "gerrit.o-ran-sc.org/r/ric-plt/sdlgo/internal/cli" "fmt" "gerrit.o-ran-sc.org/r/ric-plt/sdlgo/internal/sdlgoredis" "hash/crc32" @@ -53,7 +54,21 @@ type SyncStorage struct { func NewSyncStorage() *SyncStorage { return newSyncStorage(NewDatabase()) } - +//Function to run the health check +func runHealthCheck(dbCreateCb DbCreateCb) ([]sdlgoredis.DbState, error) { + var anyErr error + var states []sdlgoredis.DbState + for _, dbInst := range dbCreateCb().Instances { + state, err := dbInst.State() + if err != nil { + anyErr = err + } + states = append(states, *state) + } + return states, anyErr +} +//NewSyncStorage creates a new sdl instance. +//The database used as a backend is given as a parameter func newSyncStorage(db *Database) *SyncStorage { return &SyncStorage{ db: db, -- 2.16.6