Skip to content

Commit 357f88f

Browse files
author
Muhammad Luthfi Fahlevi
committed
feat: make the isolation level transaction configurable
1 parent f05f073 commit 357f88f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/store/postgres/postgres.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ type Client struct {
4242
}
4343

4444
func (c *Client) RunWithinTx(ctx context.Context, f func(tx *sqlx.Tx) error) error {
45-
tx, err := c.db.BeginTxx(ctx, nil)
45+
return c.RunWithinTxWithOption(ctx, nil, f)
46+
}
47+
48+
func (c *Client) RunWithinTxWithOption(ctx context.Context, opts *sql.TxOptions, f func(tx *sqlx.Tx) error) error {
49+
tx, err := c.db.BeginTxx(ctx, opts)
4650
if err != nil {
4751
return fmt.Errorf("starting transaction: %w", err)
4852
}

0 commit comments

Comments
 (0)