-
Type: Task
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: mongo-tools-common
-
None
Allow setting the external mongo client when creating a session provider.
I already have a mongo client i.e created for the application I want to reuse it.
// NewSessionProvider constructs a session provider, including a connected client. func NewSessionProvider(opts options.ToolOptions) (*SessionProvider, error) { // finalize auth options, filling in missing passwords if opts.Auth.ShouldAskForPassword() { pass, err := password.Prompt() if err != nil { return nil, fmt.Errorf("error reading password: %v", err) } opts.Auth.Password = pass } client, err := configureClient(opts) if err != nil { return nil, fmt.Errorf("error configuring the connector: %v", err) } err = client.Connect(context.Background()) if err != nil { return nil, err } err = client.Ping(context.Background(), nil) if err != nil { return nil, fmt.Errorf("could not connect to server: %v", err) } // create the provider return &SessionProvider{client: client}, nil }