mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 00:52:08 +08:00

* Fix UNION syntax in resourcepermissions package. * Fix migrations in usermig package to work with Spanner. * Fix health query. * Use more connections for integration tests. * Add test-go-integration-spanner target to run integration tests against Spanner emulator. * Add test for enterprise. * Don't delete sequence number for migration_log.id column. * Only bump max open connections to 20 for Spanner. Lower integration test timeout.
26 lines
498 B
Go
26 lines
498 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/db"
|
|
)
|
|
|
|
func (hs *HTTPServer) databaseHealthy(ctx context.Context) bool {
|
|
const cacheKey = "db-healthy"
|
|
|
|
if cached, found := hs.CacheService.Get(cacheKey); found {
|
|
return cached.(bool)
|
|
}
|
|
|
|
err := hs.SQLStore.WithDbSession(ctx, func(session *db.Session) error {
|
|
_, err := session.Query("SELECT 1")
|
|
return err
|
|
})
|
|
healthy := err == nil
|
|
|
|
hs.CacheService.Set(cacheKey, healthy, time.Second*5)
|
|
return healthy
|
|
}
|