feat: add IM service health and metrics endpoints

This commit is contained in:
richjohnrambo
2026-09-09 14:24:40 +08:00
parent 4c9bdd64e0
commit 9159ec7fc7
11 changed files with 616 additions and 6 deletions
+15
View File
@@ -2,6 +2,7 @@
package store
import (
"context"
"encoding/json"
"errors"
"fmt"
@@ -120,6 +121,7 @@ type PersistentStorageInterface interface {
GetUid() types.Uid
GetUidString() string
DbStats() func() any
HealthCheck(context.Context) error
GetAuthNames() []string
GetAuthHandler(name string) auth.AuthHandler
GetLogicalAuthHandler(name string) auth.AuthHandler
@@ -473,6 +475,19 @@ func (storeObj) GetAdapter() adapter.Adapter {
return adp
}
// HealthCheck verifies that the persistent storage adapter can execute a real operation.
func (storeObj) HealthCheck(ctx context.Context) error {
if adp == nil || !adp.IsOpen() {
return errors.New("store is not open")
}
if checker, ok := adp.(interface {
HealthCheck(context.Context) error
}); ok {
return checker.HealthCheck(ctx)
}
return errors.New("health check is not supported by " + adp.GetName())
}
// GetAdapterName returns the name of the current adater.
func (storeObj) GetAdapterName() string {
if adp != nil {