sql

package
v2.326.9 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 2 Imported by: 0

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

View Source
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.

func (*Config) IsEnabled added in v2.115.0

func (c *Config) IsEnabled() bool

IsEnabled reports whether SQL configuration is present.

By convention, a nil *Config is treated as "disabled".

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.

Jump to

Keyboard shortcuts

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