mongo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(host, username, password string, ops ...Option) (*mongo.Client, error)

NewConnection initialize mongodb client for connection instance.

Types

type Option

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

func WithConnectTimeoutMS

func WithConnectTimeoutMS(timeout time.Duration) Option

WithConnectTimeoutMS Specifies the number of milliseconds to wait before timeout on a TCP connection. Default value 30000.

func WithDirectConnection

func WithDirectConnection(direct bool) Option

WithDirectConnection Specifies whether to force dispatch all operations to the host specified in the connection URI. default is false.

func WithHosts

func WithHosts(hosts ...string) Option

WithHosts Specifies mongod server hosts, you can specify one or more then.

func WithMaxIdleTimeMS

func WithMaxIdleTimeMS(idletime time.Duration) Option

WithMaxIdleTimeMS Specifies the maximum amount of time a connection can remain idle in the connection pool before being removed and closed. The default is 0, meaning a connection can remain unused indefinitely.

func WithMaxPoolSize

func WithMaxPoolSize(maximum int) Option

WithMaxPoolSize Specifies the maximum number of connections that a connection pool may have at a given time. Default value 100.

func WithMinPoolSize

func WithMinPoolSize(minimum int) Option

WithMinPoolSize Specifies the minimum number of connections that the driver maintains in a single connection pool. Default value 0.

func WithPassword

func WithPassword(password string) Option

WithPassword Specifies user's password.

func WithReplicaSet

func WithReplicaSet(replica string) Option

WithReplicaSet Specifies the replica set name for the cluster. All nodes in the replica set must have the same replica set name, or the Client will not consider them as part of the set. Default value "null".

func WithSocketTimeoutMS

func WithSocketTimeoutMS(timeout time.Duration) Option

WithSocketTimeoutMS Specifies the number of milliseconds to wait for a socket read or write to return before returning a network error. The 0 default value indicates that there is no timeout.

func WithTLS

func WithTLS(enabled bool) Option

WithTLS Specifies whether to establish a Transport Layer Security (TLS) connection with the instance. This is automatically set to true when using a DNS seedlist (SRV) in the connection string. You can override this behavior by setting the value to false.

func WithUsername

func WithUsername(username string) Option

WithUsername Specifies user's username.

func WithWriteConcern

func WithWriteConcern(concern string) Option

WithWriteConcern Specifies the write concern. For more information on values, see the server documentation on Write Concern opts(https://docs.mongodb.com/manual/reference/write-concern/).

Jump to

Keyboard shortcuts

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