conn

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package conn builds a MySQL DSN from a config.Datasource and opens a pooled *sql.DB connection. SSH tunneling is added in a later task.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DSN

func DSN(ds config.Datasource) string

DSN renders a go-sql-driver/mysql DSN with tls, charset, sql_mode, timeout.

Types

type Pool

type Pool struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

Pool wraps a *sql.DB for the active datasource.

func Open

func Open(ctx context.Context, ds config.Datasource) (*Pool, error)

Open opens a pooled connection and verifies it with a Ping. When SSH is enabled, a tunnel is established first and the DSN points at the local forwarded port.

func (*Pool) Close

func (p *Pool) Close() error

Close releases the pool. If a backing SSH tunnel was established, it is torn down before the *sql.DB is closed.

func (*Pool) Ping

func (p *Pool) Ping(ctx context.Context) error

Ping verifies the connection is alive.

Jump to

Keyboard shortcuts

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