Documentation
¶
Index ¶
- func CloseAll() error
- func ErrDriverNotFound(driver string) error
- func ErrNoDatabaseConnection() error
- func ErrSessionNotFound(name string) error
- func GetAllSessions() map[string]*Session
- func GetConnectionStats() map[string]interface{}
- func GetDB(name string) (*bun.DB, error)
- func GetRedisClient() *redis.Client
- func HealthCheck(ctx context.Context) map[string]error
- func Init(configs ...Config) error
- func InitRedis(cfg RedisConfig) error
- func RegisterDriver(name string, driver DatabaseDriver)
- func WithTransaction(ctx context.Context, sessionName string, fn func(tx bun.Tx) error) error
- type Config
- type ConnectionManager
- type DatabaseDriver
- type DatabaseError
- type RedisConfig
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrDriverNotFound ¶
func ErrNoDatabaseConnection ¶
func ErrNoDatabaseConnection() error
func ErrSessionNotFound ¶
func GetAllSessions ¶
GetAllSessions returns all active sessions
func GetConnectionStats ¶
func GetConnectionStats() map[string]interface{}
GetConnectionStats returns connection statistics
func GetRedisClient ¶
GetRedisClient returns Redis client instance
func HealthCheck ¶
HealthCheck performs health check on all connections
func RegisterDriver ¶
func RegisterDriver(name string, driver DatabaseDriver)
RegisterDriver registers a database driver
Types ¶
type Config ¶
type Config struct {
Name string
Dsn string
Driver string
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
Debug bool
}
Config represents database configuration
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
ConnectionManager manages all database connections
var ( Manager *ConnectionManager RedisClient *redis.Client )
Global instances
type DatabaseDriver ¶
type DatabaseDriver interface {
Open(dsn string) (*sql.DB, error)
CreateBunDB(sqlDB *sql.DB) *bun.DB
GetDriverName() string
}
DatabaseDriver interface for dynamic driver loading
type DatabaseError ¶
Custom errors
func (*DatabaseError) Error ¶
func (e *DatabaseError) Error() string
type RedisConfig ¶
type RedisConfig struct {
Addr string
Password string
DB int
MaxRetries int
PoolSize int
MinIdleConns int
PoolTimeout time.Duration
IdleTimeout time.Duration
}
RedisConfig represents Redis configuration
Click to show internal directories.
Click to hide internal directories.