feat: add IM service health and metrics endpoints
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user