GH-15742: added db health check method in app (#15752)
Этот коммит содержится в:
19
app/app.go
19
app/app.go
@@ -10,6 +10,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/go-i18n/i18n"
|
||||
goi18n "github.com/mattermost/go-i18n/i18n"
|
||||
@@ -677,3 +678,21 @@ func (a *App) SetServer(srv *Server) {
|
||||
func (a *App) GetT() goi18n.TranslateFunc {
|
||||
return a.t
|
||||
}
|
||||
|
||||
func (a *App) DBHealthCheckWrite() error {
|
||||
currentTime := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
|
||||
return a.Srv().Store.System().SaveOrUpdate(&model.System{
|
||||
Name: a.dbHealthCheckKey(),
|
||||
Value: currentTime,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) DBHealthCheckDelete() error {
|
||||
_, err := a.Srv().Store.System().PermanentDeleteByName(a.dbHealthCheckKey())
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) dbHealthCheckKey() string {
|
||||
return fmt.Sprintf("health_check_%s", a.GetClusterId())
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user