Replace RequestStart/Done with thread agnostic concepts of "binding" and "bound objects"

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.7
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In 1.7 database and collection objects can be considered to be "bound" to a cluster, since operations can be performed against any member of the cluster (subject to any ReadPreference provided).

      The only mechanism provided to "bind" a series of operations to a single connection is RequestStart/Done. But RequestStart/Done is problematic because it relies on thread affinity, which makes it very unfriendly to a future async implementation.

      We are going to obsolete RequestStart/Done and replace it with a new concept we call "binding". In general terms, an IMongoBinding can be thought of as a source of bound objects, and a bound object is one that performs operations using a connection provided by the binding it is bound to.

      The following classes are "bindings": MongoClient/MongoServer, MongoServerInstance and MongoConnection. They represent successively tighter bindings.

      The following classes are "bound objects": MongoDatabase and MongoCollection.

      Here is some sample code showing how to perform a series of operations using a single connection:

      using (var connection = server.GetConnection())
      {
          var database = connection.GetDatabase("test"); // database is bound to the connection
          var collection = database.GetCollection("test"); // and collection is also
          // perform a series of operations
      }
      

      Note that the connection is used in a "using" statement, and will be released back to the connection pool when the using statement is left.

      This will be backward breaking if you use RequestStart/Done. In version 1.8 we are only deprecating RequestStart/Done, but in a later version it will be removed.

            Assignee:
            Robert Stam (Inactive)
            Reporter:
            Robert Stam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: