Documentation
¶
Index ¶
- Constants
- Variables
- type Connector
- type MetricCollector
- type Metrics
- type NoMetric
- type SQL
- func (db *SQL) Close() error
- func (db *SQL) NoTx(f func(*sqlx.DB) error) (err error)
- func (db *SQL) NoTxContext(ctx context.Context, f func(*sqlx.DB) error) (err error)
- func (db *SQL) Tx(ctx context.Context, opts *sql.TxOptions, f func(*sqlx.Tx) error) (err error)
- func (db *SQL) UnderlyingDB() *sql.DB
- type SQLConfig
Constants ¶
const ( DefaultSetConnMaxLifetime = time.Second * 60 DefaultSetConnMaxIdleTime = time.Second * 10 DefaultSetMaxOpenConnections = 50 DefaultSetMaxIdleConnections = 50 )
Default values for config.
Variables ¶
var ( ErrPanic = errors.New("panic") ErrRollbackFailed = errors.New("rollback failed") )
Functions ¶
This section is empty.
Types ¶
type MetricCollector ¶
type MetricCollector interface {
// Collecting collects Metrics information for handlers.
Collecting(method string, f func() error) func() error
}
MetricCollector is a helper for easy collecting metrics for every handler.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics contains general metrics for DAL methods.
func NewMetrics ¶
func NewMetrics(reg *prometheus.Registry, namespace, subsystem string, methodsFrom any) (metric Metrics)
NewMetrics registers and returns common DAL metrics used by all services (namespace).
type SQL ¶
type SQL struct {
// contains filtered or unexported fields
}
SQL is a wrapper for sql database.
func (*SQL) NoTx ¶
NoTx provides DAL method wrapper with: - converting sqlx errors which are actually bugs into panics, - general metrics for DAL methods, - wrapping errors with DAL method name.
func (*SQL) NoTxContext ¶
NoTxContext provides DAL method wrapper with: - converting sqlx errors which are actually bugs into panics, - general metrics for DAL methods, - wrapping errors with DAL method name, - tracing.
func (*SQL) Tx ¶
Tx provides DAL method wrapper with: - converting sqlx errors which are actually bugs into panics, - general metrics for DAL methods, - wrapping errors with DAL method name, - transaction.
func (*SQL) UnderlyingDB ¶
UnderlyingDB returns the underlying *sql.DB for use by metrics collectors and other components that need direct access to the connection pool stats.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package connectors contains implements for making connections to relation database.
|
Package connectors contains implements for making connections to relation database. |
|
Package internal provide helpers for database.
|
Package internal provide helpers for database. |