Ctrl Plane

PostgreSQL Store

Production-grade PostgreSQL store using Grove ORM with pgdriver.

The PostgreSQL store (store/postgres) uses the Grove ORM with pgdriver to persist data in PostgreSQL. It is the recommended store for production SQL deployments.

When to use

  • Production deployments -- battle-tested SQL database with ACID transactions.
  • PostgreSQL environments -- full query power, JSON operators, CTEs.
  • Multi-instance services -- shared database for horizontal scaling.
  • Teams familiar with SQL -- leverage existing database expertise.

Configuration

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

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

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

With the app

cp, err := app.New(
    app.WithStore(s),
)

Internals

AspectDetail
DriverGrove ORM with pgdriver (PostgreSQL)
MigrationsGrove migration orchestrator with programmatic migrations
TransactionsPostgreSQL-level ACID transactions
ConcurrencyFull MVCC with row-level locking
MigrateCreates tables, indexes, constraints
Pingdb.Ping(ctx)
CloseCloses the database connection

Limitations

  • External dependency -- requires a running PostgreSQL instance.
  • Schema migrations -- must run Migrate() before first use.

Comparison

FeatureMemoryBadgerPostgreSQLSQLiteMongoDB
SetupNonePath onlyDSNFile pathURI
PersistenceNoYesYesYesYes
Multi-processNoNoYesNoYes
Query flexibilityLowLowHighMediumHigh
Best forTestsEmbedded KVProduction SQLEmbedded SQLProduction NoSQL

On this page