Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoAvailableSlaves = errors.New("no available slave databases") ErrInvalidStrategy = errors.New("invalid load balance strategy") )
Functions ¶
func SetDriverRegistry ¶ added in v0.2.0
func SetDriverRegistry(registry DriverRegistry)
SetDriverRegistry is called by the data package to inject the registry.
Types ¶
type CacheDriver ¶ added in v0.2.0
type Connections ¶
type Connections struct {
DBM *DBManager
RC any
MS any
ES any
OS any
MGM any
Neo any
RMQ any
KFK any
// contains filtered or unexported fields
}
func (*Connections) Close ¶
func (d *Connections) Close() (errs []error)
func (*Connections) DB ¶
func (d *Connections) DB() *sql.DB
type DBManager ¶
type DBManager struct {
// contains filtered or unexported fields
}
DBManager manages database connections for read-write splitting
func NewDBManager ¶
NewDBManager creates a new database manager with read-write splitting
type DatabaseDriver ¶ added in v0.2.0
type DatabaseDriver interface {
Name() string
Connect(ctx context.Context, cfg any) (any, error)
Close(conn any) error
Ping(ctx context.Context, conn any) error
}
DatabaseDriver mirrors the interface from data package to avoid import cycle.
type DriverRegistry ¶ added in v0.2.0
type DriverRegistry interface {
GetDatabaseDriver(name string) (DatabaseDriver, error)
GetCacheDriver(name string) (CacheDriver, error)
GetSearchDriver(name string) (SearchDriver, error)
GetMessageDriver(name string) (MessageDriver, error)
}
DriverRegistry defines the minimal interface needed from data package.
type LoadBalancer ¶
LoadBalancer LoadBalancer interface
type MessageDriver ¶ added in v0.2.0
type RoundRobinBalancer ¶
type RoundRobinBalancer struct {
// contains filtered or unexported fields
}
RoundRobinBalancer Implement polling strategy
func NewRoundRobinBalancer ¶
func NewRoundRobinBalancer() *RoundRobinBalancer
NewRoundRobinBalancer Create new RoundRobinBalancer
type SearchDriver ¶ added in v0.2.0
type WeightBalancer ¶
type WeightBalancer struct {
// contains filtered or unexported fields
}
WeightBalancer Implement weight strategy
func NewWeightBalancer ¶
func NewWeightBalancer(slaves []*config.DBNode) *WeightBalancer
Click to show internal directories.
Click to hide internal directories.