mgo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWaitTimeout = errors.New("mgo: wait timeout")

ErrWaitTimeout 获取连接池对象超时

Functions

func MigrateIndex

func MigrateIndex(ctx context.Context, collection *mongo.Collection, version int, idxs []IdxKey) ([]string, error)

MigrateIndex create new version index and delete old version index

Types

type FieldDesribe

type FieldDesribe struct {
	FieldName string
	Sort      FieldSort
}

FieldDesribe field of index

type FieldSort

type FieldSort int

FieldSort int

const (
	//FieldAsc Asc
	FieldAsc FieldSort = 1
	//FieldDesc Desc
	FieldDesc FieldSort = -1
)

type IdxKey

type IdxKey struct {
	Keys []FieldDesribe
	Opt  options.IndexOptions
}

IdxKey IdxKey

type Session

type Session struct {
	Client *mongo.Client
	// contains filtered or unexported fields
}

Session mongo進程

func (*Session) Close

func (s *Session) Close()

Close 關閉連接, 並返回連接池

type SessionManager

type SessionManager interface {
	//Get 获取一个Mongodb链接
	Get() (*Session, error)
}

SessionManager session管理器

func NewSessionManager

func NewSessionManager(ctx context.Context, maxIdleConns, maxOpenConns int, waitTimeout time.Duration, opts ...*options.ClientOptions) (SessionManager, error)

NewSessionManager 初始化Session管理器实例 maxIdleConns 最大空闲连接数 waitTimeout 等待可用连接超时时间

type URI

type URI struct {
	//Hosts 主机列表
	Hosts []string
	//Database 数据库
	Database string
	//AuthDB 验证数据库
	AuthDB string
	//Login 登陆账号
	Login string
	//Passwd 登陆密码
	Passwd string
	//ReplicaSet 复制分片
	ReplicaSet string
}

ConnectionString Mongo连接信息 mongodb://[username:password@]host1[:port1][,...hostN[:portN]]][/[database][?options]]

func NewURI

func NewURI(host, database, authdb, replicaSet, login, passwd string) *URI

NewURI 创建新都连接池

func (*URI) String

func (u *URI) String() string

Jump to

Keyboard shortcuts

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