Documentation ¶
Index ¶
- Variables
- func Connect(ctx context.Context, uri, appName string) (*clientImpl, error)
- func MongoConnect(ctx context.Context, uri string, mongoOptions ...MongoOption) (*mongo.Client, error)
- func MongoConnectWithOpts(ctx context.Context, uri string, mongoOptions ...MongoOption) (*mongo.Client, *options.ClientOptions, error)
- func UnsafeClient(m *mongo.Client) *clientImpl
- type Client
- type MongoOption
- func AppName(name string) MongoOption
- func ConnectTimeout(d time.Duration) MongoOption
- func Direct(direct bool) MongoOption
- func NoRS() MongoOption
- func ReadConcern(readConcern *readconcern.ReadConcern) MongoOption
- func ServerSelectionTimeout(d time.Duration) MongoOption
- func WriteConcern(writeConcern *writeconcern.WriteConcern) MongoOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidConnection = errors.New("invalid mongo connection")
Functions ¶
func Connect ¶
Connect resolves MongoDB connection to Primary member and wraps it within Client object. In case of replica set it returns connection to Primary member, while in case of sharded cluster it returns connection to Config RS Primary member.
func MongoConnect ¶
func MongoConnectWithOpts ¶
func MongoConnectWithOpts(ctx context.Context, uri string, mongoOptions ...MongoOption, ) (*mongo.Client, *options.ClientOptions, error)
func UnsafeClient ¶
Types ¶
type Client ¶
type Client interface { Disconnect(ctx context.Context) error MongoClient() *mongo.Client MongoOptions() *options.ClientOptions ConfigDatabase() *mongo.Database AdminCommand(ctx context.Context, cmd bson.D, opts ...*options.RunCmdOptions) *mongo.SingleResult LogCollection() *mongo.Collection ConfigCollection() *mongo.Collection LockCollection() *mongo.Collection LockOpCollection() *mongo.Collection BcpCollection() *mongo.Collection RestoresCollection() *mongo.Collection CmdStreamCollection() *mongo.Collection PITRChunksCollection() *mongo.Collection PITRCollection() *mongo.Collection PBMOpLogCollection() *mongo.Collection AgentsStatusCollection() *mongo.Collection }
type MongoOption ¶
type MongoOption func(*options.ClientOptions) error
func AppName ¶
func AppName(name string) MongoOption
func ConnectTimeout ¶
func ConnectTimeout(d time.Duration) MongoOption
func Direct ¶
func Direct(direct bool) MongoOption
func ReadConcern ¶
func ReadConcern(readConcern *readconcern.ReadConcern) MongoOption
ReadConcern option sets availability guarantees for read operation. For PBM typically use: readconcern.Local or readconcern.Majority. If the option is not specified the default is: readconcern.Majority.
func ServerSelectionTimeout ¶
func ServerSelectionTimeout(d time.Duration) MongoOption
func WriteConcern ¶
func WriteConcern(writeConcern *writeconcern.WriteConcern) MongoOption
WriteConcern option sets level of acknowledgment for write operation. For PBM typically use: writeconcern.W1 or writeconcern.Majority. If the option is not specified the default is: writeconcern.Majority.
Click to show internal directories.
Click to hide internal directories.