mirror of
https://github.com/hanzoai/cloud.git
synced 2026-11-23 21:30:05 +00:00
Adds sdk/sqltest, sdk/sqlcheck and sdk/driver/{postgres,kv,s3} with the
tests they unlock. postgres.Declare names the subsystems that live on
hanzo-sql; the host declares them at start.
Claude-Session: https://claude.ai/code/session_015XYKLn69gF4x75RWePpDBV
27 lines
713 B
Go
27 lines
713 B
Go
package postgres
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
// BackOff sets how long a failed move keeps a store a file, and returns what restores
|
|
// it, for the tests of the package that move a store again.
|
|
func BackOff(d time.Duration) (restore func()) {
|
|
old := moveBackoff
|
|
moveBackoff = d
|
|
return func() { moveBackoff = old }
|
|
}
|
|
|
|
// Admin is the one connection pool the server at dsn keeps for provisioning, leases
|
|
// and registry reads, limited to one connection so that every ask runs on the same
|
|
// backend and a test can read that backend's own counters.
|
|
func Admin(dsn string) (*sql.DB, error) {
|
|
s, err := serverOf(dsn)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
s.admin.SetMaxOpenConns(1)
|
|
return s.admin, nil
|
|
}
|