mongodb

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseClose

func BaseClose(dbType string, dbKey ...string)

func BaseOpen

func BaseOpen(dbType string, options_ Options, dbKey ...string)

func Close

func Close(dbKey ...string)

func CloseMaster

func CloseMaster(dbKey ...string)

func CloseSlave

func CloseSlave(dbKey ...string)

func DB

func DB(dbKey ...string) *mongo.Database

func Master

func Master(dbKey ...string) *mongo.Database

func Open

func Open(options_ Options, dbKey ...string)

func OpenMaster

func OpenMaster(options_ Options, dbKey ...string)

func OpenSlave

func OpenSlave(options_ Options, dbKey ...string)

func SetPick

func SetPick(pk func(dbKey string, dbType string, dbs []*Pool) (*Pool, error))

func Slave

func Slave(dbKey ...string) *mongo.Database

Types

type Options

type Options struct {
	ConnMaxLifetime       time.Duration //保存连接的最大存活时间
	MaxOpenConns          int           //最大打开连接
	MaxIdleConns          int           //最大保存多少空闲连接
	StatisticsLog         bool          //是否记录统计日志
	StatisticsLogDuration time.Duration //多长时间记录一次统计日志, 默认5秒钟记录一次
}

type Pool

type Pool struct {
	MaxOpenConns int
	DatabaseName string
	Stats        *Statistics
	Client       *mongo.Client
	// contains filtered or unexported fields
}

type Statistics

type Statistics struct {
	Use  int //正在使用
	Idle int //正在空闲
}

func BaseStats

func BaseStats(dbType string, dbKey ...string) (Statistics, error)

func MasterStats

func MasterStats(dbKey ...string) (Statistics, error)

func SlaveStats

func SlaveStats(dbKey ...string) (Statistics, error)

func Stats

func Stats(dbKey ...string) (Statistics, error)

Jump to

Keyboard shortcuts

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