PostgreSQL Store
Production-ready PostgreSQL store using pgx/v5.
The PostgreSQL store uses pgx/v5 for direct database access. It is the recommended store for production deployments.
Usage
import "github.com/xraph/relay/store/postgres"
s, err := postgres.New(ctx, "postgres://user:pass@localhost:5432/relay?sslmode=disable")
if err != nil {
log.Fatal(err)
}
if err := s.Migrate(ctx); err != nil {
log.Fatal(err)
}
r, err := relay.New(relay.WithStore(s))Configuration
The store accepts a PostgreSQL connection string. Connection pooling is handled by pgx.
Migrations
Call s.Migrate(ctx) before first use. This creates all required tables and indexes.
Internals
| Aspect | Detail |
|---|---|
| Driver | pgx/v5 with connection pool |
| Migrations | Auto-create tables on Migrate() |
| Transactions | Database-level ACID |
| Ping | pool.Ping(ctx) |
| Close | Closes the connection pool |
When to use
- Production deployments.
- When you need ACID transactions and full SQL query power.
- Multi-process environments.