Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2080

Document client.StartSession does not error on disconnected client

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.7.1
    • Affects Version/s: None
    • Component/s: Connections
    • Not Needed

      The invocation of `client.StartSession( aContext )` over a `*mongo.Client`  should produce an error if the client has been previously disconnected (through `client.Disconnect( aContext )` ). Am I missing something from the DOCS?The invocation of `client.StartSession( aContext )` over a `*mongo.Client`  should produce an error if the client has been previously disconnected (through `client.Disconnect( aContext )` ). Am I missing something from the DOCS?
      To reproduce:

      ```
      import (
      "fmt"
      "context"
      "go.mongodb.org/mongo-driver/mongo"
      "go.mongodb.org/mongo-driver/mongo/options"
      )

      func main() {
          clientMongo, err := mongo.Connect(context.Background(), options.Client().ApplyURI( someUriYouProvide ))
         
          if err != nil

      {       fmt.Printf("Should not error on creating a new valid adapter: %s \n.", err)     }

          err = clientMongo.Disconnect(context.Background()) // let simulate a connection loss
          if err != nil

      {       fmt.Printf("error on disconnect: %s \n", err)     }

          // every operations over a Collection (obtained before the Disconnect) will now fail with an error, as expected
          mongoSession, err := clientMongo.StartSession()
          if err == nil

      {       fmt.Println("should give error on starting session with DISCONNECTED mongo client")     }

      }
      ```

            Assignee:
            benji.rewis@mongodb.com Benji Rewis (Inactive)
            Reporter:
            ottins1995@gmail.com Marco Ottina
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: