Documentation ¶
Index ¶
- Constants
- func CheckConnOK(client *mongo.Client) bool
- func Conn(client *mongo.Client) error
- func Disconn(client *mongo.Client) error
- func GetClient(serviceName string) *mongo.Client
- func GetClientWithOptions(serveName string, options *options.ClientOptions) *mongo.Client
- func GetLOptions() *options.ClientOptions
- func Init(opts ...Option) error
- func InitClient(opts *options.ClientOptions) *mongo.Client
- func ReleaseClient(serveName string, client *mongo.Client)
- func Reset(client *mongo.Client) error
- func SetLOptions(clientOpts *options.ClientOptions)
- type OptFunc
- type Option
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 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 InitClient ¶ added in v0.0.7
func InitClient(opts *options.ClientOptions) *mongo.Client
InitClient init mongo driver client
func ReleaseClient ¶
ReleaseClient program release a connection
func SetLOptions ¶ added in v0.0.7
func SetLOptions(clientOpts *options.ClientOptions)
SetLOptions set default global client options
Types ¶
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
Click to show internal directories.
Click to hide internal directories.