postgres

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package postgres provides a ready Postgres connection pool for dim: Resource opens it with pg.Open, checks it is reachable and closes it on shutdown.

Usage

// in an app initializer (app.Initializer[Deps]):
c.DB, cleanup = dim.NewResource("Store", postgres.Resource(pg.Config{
    User:           opts.DB.User,
    Password:       opts.DB.Password,
    Host:           opts.DB.Host,
    Name:           opts.DB.Name,
    Metrics:        c.Metrics,
    TracerProvider: c.TracerProvider,
}))
return cleanup, nil

The pool is opened on first use of c.DB. pg.Config is passed through unchanged: see the dbx/pg package for its fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resource

func Resource(cfg pg.Config) func(ctx context.Context) (*dbx.DB, dim.CleanupFunc, error)

Resource returns a dim factory that opens a connection pool from cfg (pg.Open) and verifies it (dbx.StatusCheck). The cleanup closes the pool.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL