Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-194

Implement Manager::selectServer() method to wrap SDAM server selection

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 0.4.0
    • Affects Version/s: 0.2.0
    • Component/s: None
    • Labels:
      None

      The aggregate() CRUD method in PHPLIB calls for defaulting the useCursor option to true or false depending on whether the target server is 2.6+ or not, respectively. If a Manager is freshly created and aggregate() is the first operation performed, SDAM will not even be initialized so it is impossible to make an informed decision about the server version. This is mainly because Manager construction is lazy and Manager::getServers() would return an empy array before initialization time.

      Implementing a Manager::selectServer() method that takes a ReadPreference would allow a CRUD method to select a server based on the read preference up front, set its defaults, and then target the operation directly on that server. This method would also need to manually initialize SDAM (at worst case by sending a ping command to some server) so that connections are available to select from.

      This may require two new features in libmongoc:

      • Manually trigger SDAM initialization
      • Allow querying SDAM's server selection and obtaining a server hint (outside of doing an actual operation)

      As an aside, such a server selection should be possible to implement in userland given a ReadPreference and manually calling Manager::getServers() and sorting through the info (i.e. isMaster results) and latency for all servers; however, that would require a userland implementation to kickstart SDAM with a ping if the collection of servers was empty.

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: