mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Context: Add context to /api/health calls (#40031)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) databaseHealthy() bool {
|
||||
func (hs *HTTPServer) databaseHealthy(ctx context.Context) bool {
|
||||
const cacheKey = "db-healthy"
|
||||
|
||||
if cached, found := hs.CacheService.Get(cacheKey); found {
|
||||
return cached.(bool)
|
||||
}
|
||||
|
||||
healthy := bus.Dispatch(&models.GetDBHealthQuery{}) == nil
|
||||
healthy := bus.DispatchCtx(ctx, &models.GetDBHealthQuery{}) == nil
|
||||
|
||||
hs.CacheService.Set(cacheKey, healthy, time.Second*5)
|
||||
return healthy
|
||||
|
||||
Reference in New Issue
Block a user