Re-introduce various accessors for database configuration

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Currently, the Go Driver v2 keeps Database-level settings (e.g. readConcern, readPreference, writeConcern, etc) private. Users may occasionally need to retrieve those settings. For example, when trying to construct a runCommand with "readConcern" the same as on the Database object.

      The following methods from v1 were removed in PR #1497

      • Database.WriteConcern()
      • Database.ReadConcern()
      • Database.ReadPreference()
      • Client.Timeout()

      With the reason given:

      those values were exposed specifically to support GridFS because it was in a separate package. Now that it's in the mongo package, those do not need to be exposed to support GridFS.

      The concern was that exposing a subset of accessors leaks internal state and creates an inconsistent API surface. Users will wonder why some database options are accessible but others aren't. Additionally, future driver changes (e.g. default normalization or added options) could render those getters misleading or out-of-sync.

      Definition of Done

      Compile a list of ways to uniformly expose a database configuration for users. Current alternatives:

      1. Define method signatures for each configuration (e.g. ReadConcern(), ReadPreference(), WriteConcern(), etc)
      2. Use a Database.Config() method to return a struct / options used to create the Database object.

      Determine the best solution (if any) and open a POC PR for team review. Otherwise close this ticket as a placeholder with rejection reason.

            Assignee:
            Unassigned
            Reporter:
            Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: