conn

package
v1.2.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

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