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

Provide imperative transaction API

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.4.0
    • Affects Version/s: None
    • Component/s: CRUD
    • Labels:
      None

      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.

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            ammarb Ammar Bandukwala
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: