mongoserve

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HostKey is the key of mongo host, if is cluster, use comma to split
	HostKey = "mongo.hostStr"
	// MinPoolSizeKey is the key of min pool size
	MinPoolSizeKey = "mongo.minPoolSizePerHost"
	// MaxPoolSizeKey is the key of max pool size
	MaxPoolSizeKey = "mongo.maxPoolSizePerHost"
	// ServerSelectTimeoutKey is the key of server selection timeout
	ServerSelectionTimeoutKey = "mongo.serverSelectionTimeout"
	// ConnectTimeoutKey is the key of connect timeout
	ConnectTimeoutKey = "mongo.connectTimeout"
	// SocketTimeoutKey is the key of socket timeout
	SocketTimeoutKey = "mongo.socketTimeout"
	// MaxConnIdleTimeKey is the key of max connection idle time
	MaxConnIdleTimeKey = "mongo.maxConnIdleTime"
)

conn

View Source
const (
	// AuthMechanismKey is the key of mongo auth mechanism
	AuthMechanismKey = "mongo.auth.authMechanism"
	// UsernameKey is the key of mongo username
	UsernameKey = "mongo.auth.username"
	// PasswordKey is the key of mongo password
	PasswordKey = "mongo.auth.password"
	// AuthSourceKey is the key of mongo auth source
	AuthSourceKey = "mongo.auth.authSource"
)

auth

View Source
const (
	// PreferPrimaryKey is the key of mongo read preference
	ReadPreferenceKey = "mongo.preferPrimary"
)

read preference

Variables

This section is empty.

Functions

func CheckConnOK added in v0.0.8

func CheckConnOK(client *mongo.Client) bool

func Conn added in v0.0.6

func Conn(client *mongo.Client) error

Conn connect to mongo server

func Disconn added in v0.0.7

func Disconn(client *mongo.Client) error

Disconn disconnect mongo client pool

func GetClient

func GetClient(serviceName string) *mongo.Client

GetClient returns a mongo client

func GetClientWithOptions

func GetClientWithOptions(serveName string, options *options.ClientOptions) *mongo.Client

GetClientWithOptions returns a mongo client with options

func GetLOptions added in v0.0.7

func GetLOptions() *options.ClientOptions

GetLOptions returns default global client options

func Init added in v0.0.3

func Init(opts ...Option) error

Init init module

func InitClient added in v0.0.7

func InitClient(opts *options.ClientOptions) *mongo.Client

InitClient init mongo driver client

func ReleaseClient

func ReleaseClient(serveName string, client *mongo.Client)

ReleaseClient program release a connection

func Reset added in v0.0.5

func Reset(client *mongo.Client) error

Reset reset mongo client connection state

func SetLOptions added in v0.0.7

func SetLOptions(clientOpts *options.ClientOptions)

SetLOptions set default global client options

Types

type OptFunc added in v0.0.3

type OptFunc func(opts *initOptions)

type Option added in v0.0.3

type Option interface {
	// contains filtered or unexported methods
}

Option is a function that can be passed to Init

func WithClientOpts added in v0.0.5

func WithClientOpts(clientOpts *options.ClientOptions) Option

WithClientOpts set client options

Jump to

Keyboard shortcuts

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