Documentation
¶
Overview ¶
Package postgres provides a convenience constructor for using graph.SQLCheckpointer with a real Postgres database, without callers needing to know which driver to import or how to wire up the DSN.
graph.SQLCheckpointer is already driver-agnostic (bring your own *sql.DB), so this package is intentionally thin: it registers the jackc/pgx stdlib driver, opens/pings the connection, and ensures the checkpoints table exists.
cp, db, err := postgres.New[MyState](ctx, "postgres://user:pass@localhost/mydb")
if err != nil {
log.Fatal(err)
}
defer db.Close()
compiled, _ := g.Compile(graph.WithCheckpointer[MyState](cp))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New opens a Postgres connection at dsn and returns a graph.SQLCheckpointer backed by it, with the checkpoints table (and pending_nodes/pending_sends migration) already ensured.
dsn is a standard Postgres connection string, e.g. "postgres://user:pass@localhost:5432/mydb?sslmode=disable".
The returned *sql.DB is also returned so callers can manage its lifecycle (e.g. call db.Close() on shutdown, or reuse it for other tables).
cp, db, err := postgres.New[MyState](ctx, dsn)
if err != nil { ... }
defer db.Close()
compiled, _ := g.Compile(graph.WithCheckpointer[MyState](cp))
Types ¶
This section is empty.