GH-15742: added db health check method in app (#15752)

Этот коммит содержится в:
ataboo
2020-10-03 03:38:35 -06:00
коммит произвёл GitHub
родитель 047c76b55f
Коммит 2551959504
5 изменённых файлов: 91 добавлений и 9 удалений

Просмотреть файл

@@ -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())
}