config

package
v2.273.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package config provides SQL database configuration types for go-service.

This package contains configuration structs that are typically embedded into a larger service configuration and then consumed by the SQL module wiring.

Start with `Config`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ConnMaxLifetime string `yaml:"conn_max_lifetime,omitempty" json:"conn_max_lifetime,omitempty" toml:"conn_max_lifetime,omitempty"`
	Masters         []DSN  `yaml:"masters,omitempty" json:"masters,omitempty" toml:"masters,omitempty"`
	Slaves          []DSN  `yaml:"slaves,omitempty" json:"slaves,omitempty" toml:"slaves,omitempty"`
	MaxOpenConns    int    `yaml:"max_open_conns,omitempty" json:"max_open_conns,omitempty" toml:"max_open_conns,omitempty"`
	MaxIdleConns    int    `yaml:"max_idle_conns,omitempty" json:"max_idle_conns,omitempty" toml:"max_idle_conns,omitempty"`
}

Config contains shared `database/sql` pool configuration.

It is intended to be embedded by driver-specific configuration types (for example, PostgreSQL) and consumed by the SQL wiring in this repository.

Masters and Slaves contain DSNs (connection strings) expressed as "source strings" (literal values, `file:` paths, or `env:` references).

func (*Config) IsEnabled added in v2.115.0

func (c *Config) IsEnabled() bool

IsEnabled reports whether SQL configuration is present (i.e., the config is non-nil).

type DSN

type DSN struct {
	// URL is a "source string" for the DSN (literal value, `file:`, or `env:`).
	URL string `yaml:"url,omitempty" json:"url,omitempty" toml:"url,omitempty"`
}

DSN is a SQL datasource name (connection string) configuration.

func (*DSN) GetURL

func (d *DSN) GetURL(fs *os.FS) ([]byte, error)

GetURL reads the configured DSN URL bytes from its source.

Jump to

Keyboard shortcuts

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