mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
61533a3cb4
* remove bus from health api * fix health api tests * use db health query as a method * use pointer in sqlstore mock
22 lines
426 B
Go
22 lines
426 B
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
|
|
}
|