Documentation
¶
Index ¶
- func Conn(ctx context.Context) *sqlx.DB
- func InitDefault(db *sqlx.DB)
- func Open(dsn string) (*sqlx.DB, error)
- func OpenProvider(ctx context.Context, dsn DSNProvider, opts Options) (*sqlx.DB, error)
- func OpenWithOptions(ctx context.Context, dsn string, opts Options) (*sqlx.DB, error)deprecated
- func OpenWithPool(dsn string, maxOpen, maxIdle int) (*sqlx.DB, error)
- func Raw(db *sqlx.DB) *sql.DB
- func Rebind(query string) string
- func RegisterTenant(tenantID string, db *sqlx.DB)
- func SetEngine(engine string) error
- func WithTenant(ctx context.Context, tenantID string) context.Context
- type DSNProvider
- type Engine
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Conn ¶
Conn returns the *sqlx.DB for the current tenant, or defaultDB when the context is not tenant-scoped. It returns a zero sqlx.DB pointer if neither is registered, allowing callers to check for nil.
func InitDefault ¶
InitDefault sets the global fallback connection used when ctx has no tenant.
func OpenProvider ¶
func Raw ¶
Raw returns the underlying *sql.DB to interoperate with packages that do not understand sqlx.
func RegisterTenant ¶
RegisterTenant associates tenantID with db. Call once during tenant bootstrap (e.g., after migrations).
Types ¶
type DSNProvider ¶
type DSNProvider func() string
DSNProvider returns a DSN string. Callers may fetch secrets from Vault or rotate credentials dynamically.
Click to show internal directories.
Click to hide internal directories.