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

Provide imperative transaction API

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor - P4 Minor - P4
    • 1.4.0
    • None
    • CRUD
    • 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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: