From 357f88f6823dc610d26e01dd04221d6581bb4c1a Mon Sep 17 00:00:00 2001 From: Muhammad Luthfi Fahlevi Date: Fri, 7 Feb 2025 15:02:24 +0700 Subject: [PATCH] feat: make the isolation level transaction configurable --- internal/store/postgres/postgres.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/store/postgres/postgres.go b/internal/store/postgres/postgres.go index a238a5d8..050d1625 100644 --- a/internal/store/postgres/postgres.go +++ b/internal/store/postgres/postgres.go @@ -42,7 +42,11 @@ type Client struct { } func (c *Client) RunWithinTx(ctx context.Context, f func(tx *sqlx.Tx) error) error { - tx, err := c.db.BeginTxx(ctx, nil) + return c.RunWithinTxWithOption(ctx, nil, f) +} + +func (c *Client) RunWithinTxWithOption(ctx context.Context, opts *sql.TxOptions, f func(tx *sqlx.Tx) error) error { + tx, err := c.db.BeginTxx(ctx, opts) if err != nil { return fmt.Errorf("starting transaction: %w", err) }