Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-663

Move life cycle managament of server proxy objects down to MongoServerProxyFactory

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: 1.7
    • Component/s: None
    • None
    • Minor Change
    • None
    • None
    • None
    • None
    • None
    • None

      Currently when an instance of MongoServer is created a matching MongoServerProxy is created which in turn results in the creation of a new connection pool.

      Because of this, MongoServer keeps a map of all the instances that have been created and MongoServer.Create first tries to return an existing MongoServerInstance before creating a new one.

      An existing MongoServer instance can only be returned if all the MongoServerSettings are identical. But many of the settings have nothing to do with the server itself or the connection pool, but with client side things. So for example, two MongoServerSettings that differ only in ReadPreference would result in the creation of two MongoServer objects and therefore two connection pools.

      This change would move the creation logic to reuse existing instances down into the MongoServerProxyFactory class, and the decision on whether a new proxy was needed or not would only be based on the part of the settings that are server related.

      MongoServer would become a lightweight object that could be freely created and disposed with no effect on the underlying proxies and their connection pools.

      Note also that we are planning to deprecate MongoServer, so this change is also a step in that direction. Many of the MongoServer methods would move to MongoClient.

      This could be backward breaking if you were relying in some way on the previous lifecycle behavior. For example, if you were deliberately changing some small irrelevant setting to purposely cause the creation of a new connection pool or were using reference equality to compare different MongoServer objects to each other.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: