Commit commits the transaction.
()
| 96 | |
| 97 | // Commit commits the transaction. |
| 98 | func (tx *Tx) Commit() error { |
| 99 | txDriver := tx.config.driver.(*txDriver) |
| 100 | var fn Committer = CommitFunc(func(context.Context, *Tx) error { |
| 101 | return txDriver.tx.Commit() |
| 102 | }) |
| 103 | txDriver.mu.Lock() |
| 104 | hooks := append([]CommitHook(nil), txDriver.onCommit...) |
| 105 | txDriver.mu.Unlock() |
| 106 | for i := len(hooks) - 1; i >= 0; i-- { |
| 107 | fn = hooks[i](fn) |
| 108 | } |
| 109 | return fn.Commit(tx.ctx, tx) |
| 110 | } |
| 111 | |
| 112 | // OnCommit adds a hook to call on commit. |
| 113 | func (tx *Tx) OnCommit(f CommitHook) { |
nothing calls this directly
no test coverage detected