Dispatch

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

AspectDetail
Driverpgx/v5 with connection pool
MigrationsAuto-create tables on Migrate()
TransactionsDatabase-level ACID
Pingpool.Ping(ctx)
CloseCloses the connection pool

When to use

  • Production deployments.
  • When you need ACID transactions and full SQL query power.
  • Multi-process environments.

On this page