0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-11-17 07:10:51 +01:00
dendrite/internal/sqlutil/writer_dummy.go

23 lines
396 B
Go
Raw Normal View History

package sqlutil
import (
"database/sql"
)
type DummyTransactionWriter struct {
}
func NewDummyTransactionWriter() TransactionWriter {
return &DummyTransactionWriter{}
}
func (w *DummyTransactionWriter) Do(db *sql.DB, txn *sql.Tx, f func(txn *sql.Tx) error) error {
if txn == nil {
return WithTransaction(db, func(txn *sql.Tx) error {
return f(txn)
})
} else {
return f(txn)
}
}