Documentation
¶
Overview ¶
Package sql provides SQL database wiring and helpers for go-service.
This package is the entrypoint for wiring SQL database support into Fx/Dig. It composes driver-specific modules (for example PostgreSQL via `database/sql/pg`) and exposes a small, consistent configuration shape for services (`sql.Config`).
Configuration and enablement ¶
SQL configuration is optional. By convention across go-service config types, a nil `*sql.Config` is treated as "disabled". Driver-specific configs typically follow the same convention, and constructors that depend on config often return (nil, nil) when disabled.
Master/slave pools and telemetry ¶
Driver integrations typically open master/slave connection pools, configure pool limits/lifetimes, and register OpenTelemetry instrumentation/metrics for `database/sql` connections.
Start with `Module` and `Config`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = di.Module( pg.Module, )
Module wires SQL database support into Fx/Dig.
This module is the aggregate SQL bundle used by higher-level application bundles such as `module.Server` and `module.Client`. It keeps SQL support opt-in via a single DI option while delegating backend-specific behavior to subpackages.
At present it includes only PostgreSQL support via `database/sql/pg.Module`, but the module shape is intentionally extensible for additional SQL drivers in the future.
Driver-specific constructors read DSNs/pool settings from config, open master/slave pools, register OpenTelemetry instrumentation/metrics, and attach lifecycle hooks that close pools on shutdown.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// PG configures PostgreSQL support (master/slave DSNs and shared pool settings).
//
// PostgreSQL is the only SQL backend wired by this repository today.
PG *pg.Config `yaml:"pg,omitempty" json:"pg,omitempty" toml:"pg,omitempty"`
}
Config is the root SQL database configuration for a go-service based service.
It composes driver-specific configuration for SQL backends wired by this repository. Today the built-in backend is PostgreSQL via the `PG` field, but the root shape leaves room for additional SQL backends without changing the surrounding service config layout.
Optional pointers and "enabled" semantics ¶
This config is intentionally optional. By convention across go-service configuration types, a nil *Config is treated as "SQL disabled". Driver-specific sub-configs are also pointers and are treated as optional; downstream constructors typically return (nil, nil) when a required sub-config is nil.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package config provides shared SQL (`database/sql`) configuration types for go-service.
|
Package config provides shared SQL (`database/sql`) configuration types for go-service. |
|
Package driver provides low-level SQL driver registration and connection helpers for go-service.
|
Package driver provides low-level SQL driver registration and connection helpers for go-service. |
|
Package pg provides PostgreSQL (`database/sql`) wiring and helpers for go-service.
|
Package pg provides PostgreSQL (`database/sql`) wiring and helpers for go-service. |