AcquireAdvisoryXactLockWithStringKey acquires a transaction-level advisory lock scoped by namespace and string key, blocking until the lock is available. The lock is automatically released when the transaction ends.
(ctx context.Context, tx *sql.Tx, namespace AdvisoryLockKey, key string)
| 88 | // lock scoped by namespace and string key, blocking until the lock is available. |
| 89 | // The lock is automatically released when the transaction ends. |
| 90 | func AcquireAdvisoryXactLockWithStringKey(ctx context.Context, tx *sql.Tx, namespace AdvisoryLockKey, key string) error { |
| 91 | _, err := tx.ExecContext(ctx, "SELECT pg_advisory_xact_lock($1, hashtext($2))", int32(namespace), key) |
| 92 | return err |
| 93 | } |
| 94 | |
| 95 | // Release releases the advisory lock and returns the connection to the pool. |
| 96 | // Uses context.Background() to ensure cleanup completes even if parent ctx is cancelled. |
no outgoing calls
no test coverage detected