Documentation ¶
Overview ¶
Package sqlconn provides a simple way to manage a SQL-based database connection.
Index ¶
- type CheckConnectionFunc
- type ConnectFunc
- type Option
- func WithCheckConnectionFunc(fn CheckConnectionFunc) Option
- func WithConnMaxIdleCount(maxIdle int) Option
- func WithConnMaxIdleTime(t time.Duration) Option
- func WithConnMaxLifetime(t time.Duration) Option
- func WithConnMaxOpen(maxOpen int) Option
- func WithConnectFunc(fn ConnectFunc) Option
- func WithDefaultDriver(driver string) Option
- func WithPingTimeout(t time.Duration) Option
- func WithSQLOpenFunc(fn SQLOpenFunc) Option
- func WithShutdownSignalChan(ch chan struct{}) Option
- func WithShutdownWaitGroup(wg *sync.WaitGroup) Option
- type SQLConn
- type SQLOpenFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckConnectionFunc ¶
CheckConnectionFunc is the type of function called to perform a DB connection check.
type ConnectFunc ¶
ConnectFunc is the type of function called to perform the actual DB connection.
type Option ¶
type Option func(*config)
Option is a type alias for a function that configures the DB connector.
func WithCheckConnectionFunc ¶
func WithCheckConnectionFunc(fn CheckConnectionFunc) Option
WithCheckConnectionFunc replaces the default connection check function.
func WithConnMaxIdleCount ¶
WithConnMaxIdleCount sets the maximum number of idle database connections.
func WithConnMaxIdleTime ¶
WithConnMaxIdleTime sets the maximum idle time of a database connection.
func WithConnMaxLifetime ¶
WithConnMaxLifetime sets the maximum lifetime of a database connection.
func WithConnMaxOpen ¶
WithConnMaxOpen sets the maximum number of open database connections.
func WithConnectFunc ¶
func WithConnectFunc(fn ConnectFunc) Option
WithConnectFunc replaces the default connection function.
func WithDefaultDriver ¶
WithDefaultDriver sets the default driver to use if not included in the DSN.
func WithPingTimeout ¶
WithPingTimeout sets the healthcheck ping timeout.
func WithSQLOpenFunc ¶
func WithSQLOpenFunc(fn SQLOpenFunc) Option
WithSQLOpenFunc replaces the default open database function.
func WithShutdownSignalChan ¶ added in v1.73.0
func WithShutdownSignalChan(ch chan struct{}) Option
WithShutdownSignalChan sets the shared channel uset to signal a shutdown. When the channel signal is received the database connection will be closed.
func WithShutdownWaitGroup ¶ added in v1.73.0
WithShutdownWaitGroup sets the shared waiting group to communicate externally when the databse connection is closed.