db

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package db is the GOWDK database plumbing addon. It enables the db feature and ships a thin, driver-agnostic helper for opening a *sql.DB on top of the standard library's database/sql. It is designed to pair with sqlc: you own the schema, the queries, the generated models, and all domain logic. GOWDK owns none of that and adds no driver, ORM, or query opinions.

The helper imports no SQL driver. Your application registers a driver with a blank import (for example _ "github.com/jackc/pgx/v5/stdlib") and passes its name to Open, so GOWDK carries no database dependency of its own.

Index

Constants

View Source
const DefaultPingTimeout = 5 * time.Second

DefaultPingTimeout bounds the connectivity check performed by Open.

View Source
const ImportPath = "github.com/cssbruno/gowdk/addons/db"

ImportPath is the canonical Go import path for the db addon.

Variables

This section is empty.

Functions

func Addon

func Addon() gowdk.Addon

Addon enables the database plumbing feature.

func Open

func Open(driver, dsn string) (*sql.DB, error)

Open opens a *sql.DB for the given registered driver and DSN, applies pool defaults, and verifies the connection with a bounded ping. The driver must be registered by the caller (typically via a blank import) before Open is called.

func OpenWithOptions

func OpenWithOptions(driver, dsn string, options Options) (*sql.DB, error)

OpenWithOptions is Open with explicit pool configuration.

Types

type Options

type Options struct {
	// MaxOpenConns caps total open connections. Zero means unlimited.
	MaxOpenConns int
	// MaxIdleConns caps idle connections. Zero uses the database/sql default.
	MaxIdleConns int
	// ConnMaxLifetime caps connection reuse time. Zero means unlimited.
	ConnMaxLifetime time.Duration
	// PingTimeout bounds the initial connectivity check. Defaults to 5s.
	PingTimeout time.Duration
}

Options tunes the connection pool. The zero value applies sensible defaults.

Jump to

Keyboard shortcuts

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