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

Describe ways to ease ClientOption usages for v2 migrations

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Go Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Context

      Unlike operation-level options, client options are rather complex and have a wide variety of use cases. For example, mongodb-kubernetes-operator.

      Definition of done

      List ways to mitigate pain points in the use of client options in v2.

      Maintain deprecated v1 behavior.

      To avoid causing too much migration pain, suggest we add a deprecated function called ConnectWithOptions that exactly maintains the v2 behavior of Connect(). This gives users a way to defer complex refactors required to migrate to v2 options.

      // Deprecated: Use Connect instead
      func ConnectWithOptions(opts ...*options.ClientOptions) (Client, error) {
          clientOpt := options.MergeClientOptions(opts...)
          // ...
      }
      

      Export a MergeCollectionOptions function

      mopts := MergeCollectionOptions(opt1, opt2, ...)
      client, _ := mongo.Connect(mopts)
      

      This could also be added as an method to ClientOptionsBuilder called Merge.

      Pitfalls

      Maintain deprecated v1 behavior.

      We will have to maintain MergeClientOptions until 3.0

      Export a MergeCollectionOptions function

      We will have to maintain `MergeCollectionOptions` indefinitely.

            Assignee:
            Unassigned Unassigned
            Reporter:
            preston.vasquez@mongodb.com Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: