Dispatch
1.x
Docs/Dispatch/PostgreSQL Store
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/stores/postgres.mdx

The store/postgres package implements Dispatch's store interfaces using the grove ORM with the PostgreSQL driver. It is the recommended store for production deployments.

Usage01

import (
    "github.com/xraph/grove"
    "github.com/xraph/grove/drivers/pgdriver"
    "github.com/xraph/dispatch/store/postgres"
)

db, err := grove.Open(pgdriver.Open("postgres://user:pass@localhost:5432/dispatch?sslmode=disable"))
if err != nil {
    log.Fatal(err)
}

s := postgres.New(db)
if err := s.Migrate(ctx); err != nil {
    log.Fatal(err)
}

d, err := dispatch.New(dispatch.WithStore(s))

Migrations02

Call s.Migrate(ctx) before first use. This creates all required tables and indexes. Migrations are idempotent -- safe to run on every startup.

Internals03

AspectDetail
Drivergrove ORM + pgdriver
Migrationsgrove orchestrator with embedded SQL migrations
TransactionsDatabase-level ACID
Pingdb.Ping(ctx)
CloseNo-op -- caller owns the *grove.DB lifecycle

When to use04

  • Production deployments requiring ACID transactions and full SQL query power.

  • Multi-process environments with connection pooling.

  • When you need durable storage for jobs, workflows, and events.