mongo

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v1.1.4

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v1.1.4

func NewClient(cli *mongo.Client, db *mongo.Database, rawConfig Mongo) *Client

func SetUp added in v1.1.4

func SetUp(conf Mongo) (*Client, error)

SetUp 初始化mongo.

func (*Client) Close added in v1.1.4

func (c *Client) Close() error

Close 关闭连接.

func (*Client) GetDB added in v1.2.3

func (c *Client) GetDB() *mongo.Database

GetDB 获取原生db.

func (*Client) Heartbeat added in v1.1.5

func (c *Client) Heartbeat() error

Heartbeat ping连接.

func (*Client) WatchHeartbeat added in v1.1.4

func (c *Client) WatchHeartbeat()

WatchHeartbeat 监测心跳和重连.

type Mongo added in v1.3.2

type Mongo struct {
	// Uri mongo Uri example:"mongodb://localhost:27017"
	Uri string `json:"uri" yaml:"uri"`
	// Database 数据库
	Database string `json:"database" yaml:"database"`
	// MaxOpenConnCount 最大连接数量
	MaxOpenConnCount uint64 `json:"maxOpenConnCount" yaml:"maxOpenConnCount"`
	// MinOpenConnCount 最小连接数量
	MinOpenConnCount uint64 `json:"minOpenConnCount" yaml:"minOpenConnCount"`
	// FreeMaxLifetime 闲置连接最大存活时间, 单位: 秒
	FreeMaxLifetime int `yaml:"freeMaxLifetime" json:"freeMaxLifetime"`
}

Jump to

Keyboard shortcuts

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