Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2686

Allow to external mongo client to session provider.

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: No version
    • Component/s: mongo-tools-common
    • Labels:
      None

      Description

      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
      }
      

        Attachments

          Activity

            People

            Assignee:
            tim.fogarty Tim Fogarty
            Reporter:
            nsaoly@gmail.com jeet parmar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: