Documentation
¶
Index ¶
- func AcquireLock(p *sql.DB, ctx context.Context, lockID string) (bool, int64, error)
- func AcquireLockInt64(p *sql.DB, ctx context.Context, lockID int64) (bool, error)
- func AcquireSharedLock(p *sql.DB, ctx context.Context, lockID string) (bool, int64, error)
- func AcquireSharedLockInt64(p *sql.DB, ctx context.Context, lockID int64) (bool, error)
- func AcquireTxnLock(p *sql.Tx, ctx context.Context, lockID int64) (bool, error)
- func ReleaseLock(p *sql.DB, ctx context.Context, lockID int64) (bool, error)
- func ReleaseSharedLock(p *sql.DB, ctx context.Context, lockID int64) (bool, error)
- type AdvisoryLock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireLock ¶
AcquireLock acquires a session-level postgresql advisory lock Hashes the value with xxh3 hash to generate a unique lockID see: AcquireLock
func AcquireLockInt64 ¶
AcquireLock acquires a session-level postgresql advisory lock uses pg_try_advisory_lock which returns immediately
func AcquireSharedLock ¶
AcquireLock acquires a session-level postgresql advisory lock uses pg_try_advisory_lock which returns immediately
func AcquireSharedLockInt64 ¶
AcquireLock acquires a shared session-level postgresql advisory lock uses pg_try_advisory_lock which returns immediately
func AcquireTxnLock ¶
AcquireLock acquires a transaction-level postgresql advisory lock uses pg_try_advisory_xact_lock which returns immediately
func ReleaseLock ¶
ReleaseLock releases an advisory lock and returns whether lock was released successfully or not
Types ¶
type AdvisoryLock ¶
type AdvisoryLock struct { Pid int64 `json:"pid"` // the process id of the process that acquired the lock ObjectID int64 `json:"objectID"` // ObjectID when using 32 bit lock with class id ClassID int64 `json:"classID"` // ClassID when using 32 bit lock with object id Granted bool `json:"granted"` // Whether the lock is held or not Locktype string `json:"locktype"` // the type of lock }