ExportXMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 2
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Use Case

      As a driver user
      I want a serverSelector function option on MongoClient that narrows server selection to a specific member of a replica set or a specific mongos
      So that I can target one member while the driver keeps discovering the rest of the deployment (unlike directConnection, which forces a Single topology and skips discovery). Matches PyMongo's server_selector.

      User Experience

      new MongoClient(uri, {
        serverSelector(servers) {
          const member = servers.find(s => s.address === 'db-2.example.com:27017');
          return member ? [member] : [];
        }
      });
      

      Not a URI option, since the value is a function. Omitting the option leaves selection unchanged.

      Dependencies

      N/A

      Risks/Unknowns

      • N/A

      Acceptance Criteria

      Implementation Requirements

      • Selection order follows PyMongo: read preference, tags, max staleness and overload deprioritization first; then serverSelector (before localThresholdMS); then the latency window applies to the returned list.
      • The function is not called when no server is eligible, for Single (directConnection) or load-balanced topologies, or for server-pinned operations (getMore, killCursors).
      • Writes still only see writable servers.

      Testing Requirements

      Unit and integration tests (replica set).

      Documentation Requirements

      N/A

      Follow Up Requirements

      Confirm with DBX devs whether this should be a Node/PyMongo-specific option or aligned across drivers.

      Implementation PR: https://github.com/mongodb/node-mongodb-native/pull/5078
      Related (closed): NODE-1491

            Assignee:
            Pavel Safronov
            Reporter:
            Sergey Zelenov
            None
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: