2
0

Call context.WithTimeout cancel function

This commit is contained in:
Valery Krivchikov
2018-09-15 13:23:09 +03:00
parent e44f0f24c4
commit c844a2402b
5 changed files with 24 additions and 12 deletions
+2 -1
View File
@@ -147,7 +147,8 @@ func (tx *Tx) CommitEx(ctx context.Context) error {
// defer tx.Rollback() is safe even if tx.Commit() will be called first in a
// non-error condition.
func (tx *Tx) Rollback() error {
ctx, _ := context.WithTimeout(context.Background(), 15*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
return tx.RollbackEx(ctx)
}