open 1 conn at a time

This commit is contained in:
Bel LaPointe
2026-03-09 13:26:47 -06:00
parent 515feed98b
commit bb203dbdf9

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"log"
"os"
"sync"
"time"
"gitea.bel.blue/bel/with"
@@ -30,7 +31,11 @@ func run(ctx context.Context) error {
}
for i := 0; i < *p-1; i++ {
func() {
connected := &sync.WaitGroup{}
connected.Add(1)
go with.PSQL(ctx, *c, func(pg *sql.DB) error {
connected.Done()
with.GoEvery(ctx, *d, func() {
if _, err := pg.ExecContext(ctx, `SELECT 1`); err != nil {
log.Println("!", err)
@@ -38,6 +43,8 @@ func run(ctx context.Context) error {
})
return ctx.Err()
})
connected.Wait()
}()
}
return with.PSQL(ctx, *c, func(pg *sql.DB) error {