INNER CODE UNIT · Go
testDatabaseConnection
brigadecore/brigade · v2/apiserver/main.go:381
func testDatabaseConnection(
ctx context.Context,
database *mongo.Database,
) error {
ctx, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()
return retries.ManageRetries(
ctx, // The retry loop will exit when this context expires
"database ping",
0, // "Infinite" retries
10*time.Second, // Max backoff
func() (bool, error) {
if err := database.Client().Ping(ctx, nil); err != nil {
return true, err // Retry
}
return false, nil // Success
},
)