Move transaction status methods to public Sesison

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Go Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      We would like to be able to reliably check if a session has a transaction running or the status of a transaction. Our application has wrapper helpers for managing transactions and when to start a new one vs already within one.

      However the `Client.IsTransactionRunning` and `Client.TransactionState` methods are only in the `x` package. They should be exposed on `Session` as `Session.IsTransactionRunning()` and `Session.TransactionState()` or similar.

      You can currently access via `Session.ClientSession().*` but that is deprecated and uses the `/x/` package.

      https://pkg.go.dev/go.mongodb.org/mongo-driver/v2@v2.4.1/x/mongo/driver/session#Client

       

      https://pkg.go.dev/go.mongodb.org/mongo-driver/v2@v2.4.1/x/mongo/driver/session#Client.TransactionRunning

       

      Definition of done

      Expose or move `Client.TransactionState` and `Client.IsTransactionRunning()` to public api on `Session.TransactionState()` and `Session.IsTransactionRunning()`

      Pitfalls

      There is potential that the transaction APIs might change however the general idea of exposing if a session has a running transaction or not should definitely be a thing. Right now we have to blacklist direct usage of the mongo transaction APIs outside of our transaction wrapper in order to add any extra behaviors. If this was added then we could support both just with less features.

            Assignee:
            Matt Dale
            Reporter:
            Ed Pelc
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: