Files
uptimesebi/internal/platform/postgres.go
Sebastian UnterschützandClaude Opus 5.5 d20225982a refactor: follow the google go style guide
Document every package and exported identifier, return the log level
from NewLogger instead of keeping it in a package variable, and stop
tests from mutating the argon2 parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:18:02 +01:00

28 lines
691 B
Go

// Package platform wires the infrastructure shared by all commands:
// logging, Postgres, Redis, HTTP serving and health probes.
package platform
import (
"context"
"fmt"
"github.com/jackc/pgx/v5/pgxpool"
)
// OpenPostgres connects a pool and verifies it with a ping.
func OpenPostgres(ctx context.Context, url string) (*pgxpool.Pool, error) {
cfg, err := pgxpool.ParseConfig(url)
if err != nil {
return nil, fmt.Errorf("postgres: %w", err)
}
pool, err := pgxpool.NewWithConfig(ctx, cfg)
if err != nil {
return nil, fmt.Errorf("postgres: %w", err)
}
if err := pool.Ping(ctx); err != nil {
pool.Close()
return nil, fmt.Errorf("postgres: %w", err)
}
return pool, nil
}