Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdvisoryLock ¶
type AdvisoryLock struct { LockID int // contains filtered or unexported fields }
AdvisoryLock represents an advisory lock. See https://www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS
func NewAdvisoryLock ¶
func NewAdvisoryLock(pool *pgxpool.Pool, lockID int) (*AdvisoryLock, error)
NewAdvisoryLock creates a new AdvisoryLock.
func (*AdvisoryLock) IsLocked ¶
func (al *AdvisoryLock) IsLocked() bool
func (*AdvisoryLock) Release ¶
func (al *AdvisoryLock) Release() bool
Release releases a single advisory lock. Returns whether unlocking was successful or not (doesn't own lock, failed...). Note that stacked lock requests require the same number of Release calls.
func (*AdvisoryLock) ReleaseConn ¶
func (al *AdvisoryLock) ReleaseConn()
ReleaseConn releases the connection to the pool. It will not guarantee lock release.
func (*AdvisoryLock) TryLock ¶
func (al *AdvisoryLock) TryLock(ctx context.Context) (bool, error)
TryLock tries to acquire the advisory lock. Returns whether the lock was acquired and any error.
func (*AdvisoryLock) WaitForRelease ¶
func (al *AdvisoryLock) WaitForRelease(retryCount int, d time.Duration) error
WaitForRelease waits for the advisory lock to be released by another session. Returns an error if the wait times out.