Documentation/Infrastructure
Infrastructure

Database and Drivers

Use database/sql through driver wrappers and normalize provider-specific errors.

Native SQL foundation

Go's database/sql package provides connection pooling and a common database API. A concrete driver still supplies the wire protocol and provider-specific behavior.

Gorix can keep the application-facing database layer stable while driver wrappers adapt PostgreSQL, MySQL, SQL Server, Oracle, and SQLite implementations.

Driver selection

Configuration can select a registered driver by name:

database:
  default:
    driver: postgres
    dsn: ${DATABASE_URL}
    max_open_connections: 30
    max_idle_connections: 10

Normalized errors

Provider error codes should be mapped into framework-level categories rather than parsed from human-readable messages.

type ErrorKind string

const (
    ErrorDuplicateKey    ErrorKind = "duplicate_key"
    ErrorForeignKey      ErrorKind = "foreign_key_violation"
    ErrorNotNull         ErrorKind = "not_null_violation"
    ErrorDeadlock        ErrorKind = "deadlock"
    ErrorTimeout         ErrorKind = "timeout"
    ErrorConnection      ErrorKind = "connection_error"
)

Repository boundary

Repositories should expose domain-focused interfaces while accepting context.Context for cancellation, deadlines, and tracing.