feat: add IM service health and metrics endpoints
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package mock_store
|
||||
|
||||
import (
|
||||
context "context"
|
||||
json "encoding/json"
|
||||
reflect "reflect"
|
||||
time "time"
|
||||
@@ -138,6 +139,20 @@ func (mr *MockPersistentStorageInterfaceMockRecorder) GetAuthNames() *gomock.Cal
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAuthNames", reflect.TypeOf((*MockPersistentStorageInterface)(nil).GetAuthNames))
|
||||
}
|
||||
|
||||
// HealthCheck mocks base method.
|
||||
func (m *MockPersistentStorageInterface) HealthCheck(ctx context.Context) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HealthCheck", ctx)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// HealthCheck indicates an expected call of HealthCheck.
|
||||
func (mr *MockPersistentStorageInterfaceMockRecorder) HealthCheck(ctx interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealthCheck", reflect.TypeOf((*MockPersistentStorageInterface)(nil).HealthCheck), ctx)
|
||||
}
|
||||
|
||||
// GetDbVersion mocks base method.
|
||||
func (m *MockPersistentStorageInterface) GetDbVersion() int {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
@@ -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