Adding health check for the reddis db. 60/10860/2
authorsmahana123 <s.mahana@samsung.com>
Thu, 6 Apr 2023 11:36:51 +0000 (17:06 +0530)
committersmahana123 <s.mahana@samsung.com>
Thu, 6 Apr 2023 11:42:27 +0000 (17:12 +0530)
Signed-off-by: smahana123 <s.mahana@samsung.com>
Change-Id: Ifae98b741b28df12679112b32212618030e54720

syncstorage.go

index 349bcc3..66f93a1 100644 (file)
@@ -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,