Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2656

Refactor mongoc_cmd_parts_assemble, part 2

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: 1.10.0
    • Fix Version/s: None
    • Component/s: libmongoc
    • Labels:
      None

      Description

      mongoc_cmd_parts_assemble was introduced to improve options-handling flow among libmongoc layers for server commands that take a combination of user-supplied arguments and arguments added by the driver. Now that we've implemented sessions, retryable writes, and transactions, so much complexity has accumulated in mongoc_cmd_parts_assemble that it needs another overhaul.

      Currently, we think in terms of "options sources": the default source (URI, client, db, or collection), the user-supplied arguments in "opts", the session, the session's default transaction options, the current transaction's options, retryability (for txnNumber and stmtId), and the transaction itself (for txnNumber, startTransaction, and autocommit). As a mongoc_cmd_parts_t descends through layers of the driver, each option source may overwrite some of the options set by previous sources.

      The rules about which sources may overwrite which are confusing. The main problem is that, by the time we call mongoc_cmd_parts_assemble, we've forgotten which options came from the default source and which were supplied by the user in "opts". It will help to maintain this distinction until we call mongoc_cmd_parts_assemble. It will also help to make the "options sources" concept less implicit and more explicit in our internal logic.

      Additionally, let's add a second concept to our thinking: "options fields". These include read concern, write concern, read preference, txnNumber, etc. For each options field, we can write a function that takes a mongoc_cmd_parts_t, inspects all the options sources, and determines the value of the options field. Splitting up the logic this way should be much clearer.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: