Versions in this module Expand all Collapse all v1 v1.2.3 Sep 4, 2025 Changes in this version + var ErrAlreadyClosed = errors.New("database already closed") + var ErrNotConnected = errors.New("database not connected") + type BaseSQLPlugin struct + func NewBaseSQLPlugin(id, name, desc, version, confPrefix string, weight int, ...) *BaseSQLPlugin + func (p *BaseSQLPlugin) CheckHealth() error + func (p *BaseSQLPlugin) CleanupTasks() error + func (p *BaseSQLPlugin) GetDB() (*sql.DB, error) + func (p *BaseSQLPlugin) GetDialect() string + func (p *BaseSQLPlugin) GetMetricsRecorder() MetricsRecorder + func (p *BaseSQLPlugin) GetStats() *ConnectionPoolStats + func (p *BaseSQLPlugin) InitializeResources(rt plugins.Runtime) error + func (p *BaseSQLPlugin) IsConnected() bool + func (p *BaseSQLPlugin) SetMetricsRecorder(recorder MetricsRecorder) + func (p *BaseSQLPlugin) StartupTasks() error + type ConnectionPoolStats struct + Idle int64 + InUse int64 + MaxIdleClosed int64 + MaxIdleConnections int64 + MaxLifetimeClosed int64 + MaxOpenConnections int64 + OpenConnections int64 + WaitCount int64 + WaitDuration time.Duration + type HealthCheckable interface + CheckHealth func() error + Name func() string + type HealthChecker struct + func NewHealthChecker(target HealthCheckable, interval time.Duration, customQuery string) *HealthChecker + func (h *HealthChecker) IsHealthy() bool + func (h *HealthChecker) Start(ctx context.Context) + func (h *HealthChecker) Stop() + type MetricsConfig struct + Enabled bool + Labels map[string]string + Namespace string + SlowQueryThreshold time.Duration + Subsystem string + func DefaultMetricsConfig() *MetricsConfig + type MetricsRecorder interface + IncConnectAttempt func() + IncConnectFailure func() + IncConnectRetry func() + IncConnectSuccess func() + RecordConnectionPoolStats func(stats *ConnectionPoolStats) + RecordHealthCheck func(success bool) + RecordQuery func(duration time.Duration, err error, threshold time.Duration) + RecordTx func(duration time.Duration, committed bool) + type NoOpMetricsRecorder struct + func (n *NoOpMetricsRecorder) IncConnectAttempt() + func (n *NoOpMetricsRecorder) IncConnectFailure() + func (n *NoOpMetricsRecorder) IncConnectRetry() + func (n *NoOpMetricsRecorder) IncConnectSuccess() + func (n *NoOpMetricsRecorder) RecordConnectionPoolStats(stats *ConnectionPoolStats) + func (n *NoOpMetricsRecorder) RecordHealthCheck(success bool) + func (n *NoOpMetricsRecorder) RecordQuery(duration time.Duration, err error, threshold time.Duration) + func (n *NoOpMetricsRecorder) RecordTx(duration time.Duration, committed bool) + type PrometheusMetrics struct + func NewPrometheusMetrics(config *MetricsConfig) *PrometheusMetrics + func (pm *PrometheusMetrics) GetGatherer() prometheus.Gatherer + func (pm *PrometheusMetrics) IncConnectAttempt() + func (pm *PrometheusMetrics) IncConnectFailure() + func (pm *PrometheusMetrics) IncConnectRetry() + func (pm *PrometheusMetrics) IncConnectSuccess() + func (pm *PrometheusMetrics) RecordConnectionPoolStats(stats *ConnectionPoolStats) + func (pm *PrometheusMetrics) RecordHealthCheck(success bool) + func (pm *PrometheusMetrics) RecordQuery(duration time.Duration, err error, threshold time.Duration) + func (pm *PrometheusMetrics) RecordTx(duration time.Duration, committed bool)