We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8e8bf1 commit 4ceab0fCopy full SHA for 4ceab0f
tx.go
@@ -65,16 +65,13 @@ func (c *Tx) Process(ctx context.Context, cmd Cmder) error {
65
// The transaction is automatically closed when fn exits.
66
func (c *Client) Watch(ctx context.Context, fn func(*Tx) error, keys ...string) error {
67
tx := c.newTx(ctx)
68
+ defer tx.Close(ctx)
69
if len(keys) > 0 {
70
if err := tx.Watch(ctx, keys...).Err(); err != nil {
- _ = tx.Close(ctx)
71
return err
72
}
73
74
-
75
- err := fn(tx)
76
77
- return err
+ return fn(tx)
78
79
80
// Close closes the transaction, releasing any open resources.
0 commit comments