Skip to content

Commit

Permalink
chore: synchronize workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed May 7, 2024
1 parent 8f9df12 commit b03cc94
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions storage/transactional.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,34 @@ package storage

import "context"

// A storage provider that has support for transactions should implement this
// interface to ensure atomicity for certain flows that require transactional
// semantics. When atomicity is required, Fosite will group calls to the storage
// provider in a function and passes that to Transaction. Implementations are
// Transactional should be implemented by storage providers that support
// transactions to ensure atomicity for certain flows that require transactional
// semantics. When atomicity is required, Ory Fosite will group calls to the storage
// provider in a function and passes that to Transaction. Implementations are
// expected to execute these calls in a transactional manner. Typically, a
// handle to the transaction will be stored in the context.
//
// Implementations should rollback (or retry) the transaction if the callback
// returns an error.
//
// function Transcation(ctx context.Context, f func(context.Context) error) error {
// tx, err := storage.BeginTx(ctx)
// if err != nil {
// return err
// }
//
// defer function() {
// if err != nil {
// tx.Rollback()
// }
// }()
//
// if err := f(tx); err != nil {
// return err
// }
//
// return tx.Commit()
// }
type Transactional interface {
Transaction(context.Context, func(context.Context) error) error
}
Expand Down

0 comments on commit b03cc94

Please sign in to comment.