heimdall

package
v0.0.0-...-a7d0425 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package heimdall manages the acquisition of a lock from PostgreSQL via the `pg_try_advisory_lock(int, int)` function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

type Lock struct {
	Database  *sql.DB
	Namespace int32
	Name      int32
}

Lock represents the components of a `pg_try_advisory_lock` lock.

func New

func New(database, namespace, name string) (lock *Lock, err error)

New establishes a connection to the PostgreSQL database with a connection string and creates a Lock.

func (*Lock) Acquire

func (l *Lock) Acquire() (lockStatus bool, err error)

Acquire attempts to acquire a lock from PostgreSQL using `pg_try_advisory_lock`.

func (*Lock) Release

func (l *Lock) Release()

Release closes the connection to the database, which releases the lock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL