Documentation
¶
Overview ¶
Package driver provides SQL driver registration and adapter helpers for go-service.
This package contains small pieces that integrate specific `database/sql`-compatible drivers with the SQL wiring in this repository (for example by registering a driver or exposing driver-specific helpers).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open opens master/slave `database/sql` connection pools for a previously registered driver name.
It resolves DSNs from cfg using the provided filesystem (DSNs are configured as go-service "source strings"), connects using `mssqlx.ConnectMasterSlaves`, registers OpenTelemetry DB stats metrics for each pool, and then applies pool settings (connection lifetime, max idle, and max open connections).
Lifecycle:
- Open appends an OnStop hook to the provided lifecycle that closes all returned pools by calling Destroy.
Errors:
- Returns any error encountered while resolving DSNs, connecting, or parsing ConnMaxLifetime.
func Register ¶
Register registers a `database/sql` driver under name and wraps it with OpenTelemetry instrumentation.
This function registers the wrapped driver with the global `database/sql` driver registry. It is therefore intended to be called during process initialization (for example from an init hook or DI registration).
Telemetry:
- The driver is wrapped using otelsql.WrapDriver.
- The DB system name attribute is set to the provided name (semconv.DBSystemNameKey).
Errors:
- If the underlying `sql.Register` panics (for example, due to registering the same name more than once), Register converts that panic into an error and returns it.