MCPcopy Create free account
hub / github.com/apecloud/myduckserver / waitForSqlServerToStart

Function waitForSqlServerToStart

pgserver/logrepl/common_test.go:79–96  ·  view source on GitHub ↗

waitForSqlServerToStart polls the specified database to wait for it to become available, pausing between retry attempts, and returning an error if it is not able to verify that the database is available.

(dsn string)

Source from the content-addressed store, hash-verified

77// between retry attempts, and returning an error if it is not able to verify that the database is
78// available.
79func waitForSqlServerToStart(dsn string) error {
80 fmt.Printf("Waiting for server to start...\n")
81 ctx := context.Background()
82 for counter := 0; counter < 30; counter++ {
83 conn, err := pgx.Connect(ctx, dsn)
84 if err == nil {
85 err = conn.Ping(ctx)
86 conn.Close(ctx)
87 if err == nil {
88 return nil
89 }
90 }
91 fmt.Printf("not up yet; waiting...\n")
92 time.Sleep(500 * time.Millisecond)
93 }
94
95 return nil
96}

Callers 1

StartPostgresServerFunction · 0.85

Calls 2

CloseMethod · 0.65
ConnectMethod · 0.45

Tested by

no test coverage detected