golazy.dev
–
golazy.dev
/
pg
Index
|
Files
|
Directories
package pg ¶
import "golazy.dev/pg"
Functions ¶
func FromContext ¶
FromContext returns the PostgreSQL pool carried by ctx.
func FromContext(ctx context.Context) (*pgxpool.Pool, bool)
func Open ¶
Open creates a pgx pool for databaseURL.
func Open(ctx context.Context, databaseURL string) (*pgxpool.Pool, error)
func OpenEnv ¶
OpenEnv creates a pgx pool from the first non-empty environment variable in names. If names is empty, DATABASE_URL is used.
func OpenEnv(ctx context.Context, names ...string) (*pgxpool.Pool, error)
func WithPool ¶
WithPool returns a context carrying pool.
func WithPool(ctx context.Context, pool *pgxpool.Pool) context.Context
Directories ¶
| Path | Synopsis |
|---|---|
| pg/pgfiles | Package pgfiles implements a PostgreSQL repository for golazy.dev/lazyfiles. |
| pg/pgjobs | Package pgjobs implements a PostgreSQL backend for golazy.dev/lazyjobs. |
| pg/pgmedia | Package pgmedia implements a PostgreSQL repository for golazy.dev/lazymedia. |
| pg/pgmigrate | Package pgmigrate implements PostgreSQL migrations for golazy.dev/lazymigrate. |
| pg/pgstorage | Package pgstorage implements a PostgreSQL object store for golazy.dev/lazystorage. |
| pg/withpg | Package withpg starts embedded PostgreSQL servers for local development and integration tests. |
| pg/withpg/cmd/withpg |
Package pg contains PostgreSQL helpers shared by concrete GoLazy PostgreSQL backends and applications.
The package is intentionally small: it stores an application-owned pgxpool.Pool on context with WithPool and retrieves it with FromContext. That keeps database ownership in the application while allowing backend packages such as pgmigrate, pgjobs, and other pg/* implementations to share the same connection pool.
lazyapp does not create a PostgreSQL pool by default. Applications normally create the pool in lazyapp.Config.Dependencies, attach it with WithPool, and let database-backed services or jobs read it back from context.