dbpool

package
v0.0.0-...-055c042 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AliasMaster  = "master"
	AliasReplica = "replica"
)

Variables

This section is empty.

Functions

func BuildAlias

func BuildAlias(alias DBAlias, instanceAlias string) string

Types

type DB

type DB struct {
	*gorm.DB
}

func NewDB

func NewDB(db *gorm.DB) *DB

func (*DB) WithContext

func (db *DB) WithContext(ctx context.Context) *DB

func (*DB) WithLogger

func (db *DB) WithLogger(logger logger.Interface) *DB

type DBAlias

type DBAlias string
const (
	// Specific db connections alias here
	DBDefault DBAlias = "default"
)

func ParseAlias

func ParseAlias(alias string) (DBAlias, string)

type DBPool

type DBPool interface {
	GetMaster(alias DBAlias) *DB
	GetReplica(alias DBAlias) *DB
	GetDB(alias string) *DB
	GetDBForce(alias string, index uint32) *DB
	SetDB(alias string, repo *DB)
}

func NewDBPool

func NewDBPool() DBPool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL