Files
grafana/pkg/api/health.go
T

22 lines
426 B
Go
Raw Normal View History

package api
import (
"context"
"time"
"github.com/grafana/grafana/pkg/models"
)
func (hs *HTTPServer) databaseHealthy(ctx context.Context) bool {
const cacheKey = "db-healthy"
if cached, found := hs.CacheService.Get(cacheKey); found {
return cached.(bool)
}
2022-02-04 14:33:35 +01:00
healthy := hs.SQLStore.GetDBHealthQuery(ctx, &models.GetDBHealthQuery{}) == nil
hs.CacheService.Set(cacheKey, healthy, time.Second*5)
return healthy
}