Documentation
¶
Overview ¶
Package postgres provides a reviewed pgx-backed database/sql starter for Spice applications.
Index ¶
- func BatchSchemaSQL(options BatchOptions) (string, error)
- func Manifest() spicestarter.Manifest
- func NewBatchStore(executor data.Executor, options BatchOptions) (*spicebatch.SQLStore, error)
- func NewOutboxStore(executor data.Executor, options OutboxOptions) (*outbox.SQLStore, error)
- func Open(options Options) (*sql.DB, error)
- func OutboxSchemaSQL(options OutboxOptions) (string, error)
- func Ping(ctx context.Context, database *sql.DB) error
- type BatchOptions
- type MigrationBackend
- type MigrationOptions
- type Options
- type OutboxOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchSchemaSQL ¶
func BatchSchemaSQL(options BatchOptions) (string, error)
BatchSchemaSQL returns the deterministic initial table DDL for an application-owned migration. It performs no database operation.
func Manifest ¶
func Manifest() spicestarter.Manifest
Manifest returns PostgreSQL starter compatibility and review metadata.
func NewBatchStore ¶
func NewBatchStore( executor data.Executor, options BatchOptions, ) (*spicebatch.SQLStore, error)
NewBatchStore constructs a lease-aware PostgreSQL batch store without connecting or applying schema changes.
func NewOutboxStore ¶
NewOutboxStore constructs a PostgreSQL outbox store without connecting or applying schema changes.
func Open ¶
Open validates a complete connection URL and constructs a caller-owned database/sql pool. It performs no network I/O.
func OutboxSchemaSQL ¶
func OutboxSchemaSQL(options OutboxOptions) (string, error)
OutboxSchemaSQL returns deterministic initial DDL for an application-owned migration. It performs no database operation.
Types ¶
type BatchOptions ¶
type BatchOptions struct {
Schema string
Table string
AttemptLease time.Duration
Clock func() time.Time
}
BatchOptions configures PostgreSQL-backed batch attempt persistence. Schema and Table must already be covered by an application-owned migration. Empty values select public.spice_batch_execution.
type MigrationBackend ¶
type MigrationBackend struct {
// contains filtered or unexported fields
}
MigrationBackend applies module-owned migration plans through one caller-owned PostgreSQL pool.
func NewMigrationBackend ¶
func NewMigrationBackend( database *sql.DB, options MigrationOptions, ) (*MigrationBackend, error)
NewMigrationBackend constructs a PostgreSQL migration backend without connecting. The backend creates its fixed registry table on first use.
func (*MigrationBackend) RunLocked ¶
func (backend *MigrationBackend) RunLocked( ctx context.Context, work func(context.Context, spicemigration.Session) error, ) error
RunLocked pins one pgx connection, obtains a session-level advisory lock, and invokes work exactly once. Unlock failure closes the physical connection so a leaked session lock can never return to the pool.
type MigrationOptions ¶
MigrationOptions configures the PostgreSQL implementation of the core migration backend. Schema must already exist. LockID zero selects Spice's stable process-independent default advisory lock.
type Options ¶
type Options struct {
URL string
ApplicationName string
MaxOpenConnections int
MaxIdleConnections int
ConnectionMaxLifetime time.Duration
ConnectionMaxIdleTime time.Duration
AllowInsecure bool
}
Options defines a PostgreSQL pool. URL must be a complete postgres or postgresql URL so connection behavior never falls back to process environment variables.
type OutboxOptions ¶
OutboxOptions configures PostgreSQL-backed durable event publication. Schema and Table must already be covered by an application-owned migration. Empty values select public.spice_event_outbox.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
starter-postgres-release
command
Command starter-postgres-release builds deterministic signed source releases.
|
Command starter-postgres-release builds deterministic signed source releases. |
|
internal
|
|
|
corecompat
command
Command corecompat verifies the PostgreSQL starter against an explicit Spice core compatibility line without changing the repository module graph.
|
Command corecompat verifies the PostgreSQL starter against an explicit Spice core compatibility line without changing the repository module graph. |
|
qualitygate
command
Command qualitygate runs starter-postgres's repository-owned checks.
|
Command qualitygate runs starter-postgres's repository-owned checks. |
|
release
Package release builds deterministic, signed starter-postgres source releases.
|
Package release builds deterministic, signed starter-postgres source releases. |