Versions in this module Expand all Collapse all v2 v2.1.2 Apr 27, 2024 Changes in this version type DB + ExecContext func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) v2.1.1 Apr 27, 2024 Changes in this version + const Commit + const ReleaseTime + const Version + type Conn interface + BeginTx func(ctx context.Context, opts *sql.TxOptions) (Tx, error) + Close func() error + ExecContext func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + PingContext func(ctx context.Context) error + PrepareContext func(ctx context.Context, query string) (Stmt, error) + QueryContext func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + QueryRowContext func(ctx context.Context, query string, args ...interface{}) *sql.Row + Raw func(f func(driverConn interface{}) error) (err error) + type DB interface + Begin func() (Tx, error) + BeginTx func(ctx context.Context, opts *sql.TxOptions) (Tx, error) + Close func() error + Conn func(ctx context.Context) (Conn, error) + Driver func() driver.Driver + Exec func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + Ping func() error + PingContext func(ctx context.Context) error + Prepare func(query string) (Stmt, error) + PrepareContext func(ctx context.Context, query string) (Stmt, error) + PrimaryDBs func() []*sql.DB + Query func(query string, args ...interface{}) (*sql.Rows, error) + QueryContext func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + QueryRow func(query string, args ...interface{}) *sql.Row + QueryRowContext func(ctx context.Context, query string, args ...interface{}) *sql.Row + ReplicaDBs func() []*sql.DB + SetConnMaxIdleTime func(d time.Duration) + SetConnMaxLifetime func(d time.Duration) + SetMaxIdleConns func(n int) + SetMaxOpenConns func(n int) + Stats func() sql.DBStats + func New(opts ...OptionFunc) DB + type DBConnection interface + type DBLoadBalancer LoadBalancer[*sql.DB] + type DefaultQueryTypeChecker struct + func (c DefaultQueryTypeChecker) Check(query string) QueryType + type LoadBalancer interface + Name func() LoadBalancerPolicy + Resolve func([]T) T + type LoadBalancerPolicy string + const RandomLB + const RoundRobinLB + type Option struct + DBLB DBLoadBalancer + PrimaryDBs []*sql.DB + QueryTypeChecker QueryTypeChecker + ReplicaDBs []*sql.DB + StmtLB StmtLoadBalancer + type OptionFunc func(opt *Option) + func WithLoadBalancer(lb LoadBalancerPolicy) OptionFunc + func WithPrimaryDBs(primaryDBs ...*sql.DB) OptionFunc + func WithQueryTypeChecker(checker QueryTypeChecker) OptionFunc + func WithReplicaDBs(replicaDBs ...*sql.DB) OptionFunc + type QueryType int + const QueryTypeRead + const QueryTypeUnknown + const QueryTypeWrite + type QueryTypeChecker interface + Check func(query string) QueryType + type RandomLoadBalancer struct + func (lb RandomLoadBalancer[T]) Name() LoadBalancerPolicy + func (lb RandomLoadBalancer[T]) Resolve(dbs []T) T + type RoundRobinLoadBalancer struct + func (lb *RoundRobinLoadBalancer[T]) Resolve(dbs []T) T + func (lb RoundRobinLoadBalancer[T]) Name() LoadBalancerPolicy + type Stmt interface + Close func() error + Exec func(...interface{}) (sql.Result, error) + ExecContext func(ctx context.Context, args ...interface{}) (sql.Result, error) + Query func(...interface{}) (*sql.Rows, error) + QueryContext func(ctx context.Context, args ...interface{}) (*sql.Rows, error) + QueryRow func(args ...interface{}) *sql.Row + QueryRowContext func(ctx context.Context, args ...interface{}) *sql.Row + type StmtLoadBalancer LoadBalancer[*sql.Stmt] + type Tx interface + Commit func() error + Exec func(query string, args ...interface{}) (sql.Result, error) + ExecContext func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + Prepare func(query string) (Stmt, error) + PrepareContext func(ctx context.Context, query string) (Stmt, error) + Query func(query string, args ...interface{}) (*sql.Rows, error) + QueryContext func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + QueryRow func(query string, args ...interface{}) *sql.Row + QueryRowContext func(ctx context.Context, query string, args ...interface{}) *sql.Row + Rollback func() error + Stmt func(stmt Stmt) Stmt + StmtContext func(ctx context.Context, stmt Stmt) Stmt