Revision b9d449529a1ee1959226ab3676d5c11181d5ca26 authored by Dimitris Sotirakis on 13 October 2022, 08:35:05 UTC, committed by GitHub on 13 October 2022, 08:35:05 UTC
1 parent 97730ae
Raw File
health.go
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)
	}

	healthy := hs.SQLStore.GetDBHealthQuery(ctx, &models.GetDBHealthQuery{}) == nil

	hs.CacheService.Set(cacheKey, healthy, time.Second*5)
	return healthy
}
back to top