Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1104

Provide imperative transaction API

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Scheduled
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 1.4.0
    • Component/s: CRUD
    • Labels:
      None

      Description

      This issue follows from the GitHub discussion here: https://github.com/mongodb/mongo-go-driver/pull/161.

      Basically, I believe that we should provide a transaction API similar to `database/sql` for these reasons:

      The callback API is unfortunate to work with in real-world code. Even if there are concurrency problems, I would much prefer this as an option with clear documentation than be forced to use callbacks.

      Within the callback, it's more difficult to return the outer function or initialize outer variables. This leads to variable shadowing, interface type assertions, and duplicated error handling. All of which significantly increase the volume of code, and the probability of bugs.

      Lastly, Go packages should take inspiration from the stdlib as much as possible for a consistent user experience. The Go authors decided to avoid the callback API in database/sql.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: