Add dbx library: PostgreSQL cluster with master/replica routing, retry, health checking

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 00:01:15 +03:00
parent 164c6a5723
commit 62df3a2eb3
21 changed files with 1607 additions and 0 deletions

35
options_test.go Normal file
View File

@@ -0,0 +1,35 @@
package dbx
import (
"testing"
"time"
)
func TestApplyOptions(t *testing.T) {
cfg := Config{}
logger := nopLogger{}
metrics := &MetricsHook{}
retry := RetryConfig{MaxAttempts: 7}
hc := HealthCheckConfig{Interval: 10 * time.Second}
ApplyOptions(&cfg,
WithLogger(logger),
WithMetrics(metrics),
WithRetry(retry),
WithHealthCheck(hc),
)
if cfg.Logger == nil {
t.Error("Logger should be set")
}
if cfg.Metrics == nil {
t.Error("Metrics should be set")
}
if cfg.Retry.MaxAttempts != 7 {
t.Errorf("Retry.MaxAttempts = %d, want 7", cfg.Retry.MaxAttempts)
}
if cfg.HealthCheck.Interval != 10*time.Second {
t.Errorf("HealthCheck.Interval = %v, want 10s", cfg.HealthCheck.Interval)
}
}