lock

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package lock implements generic application-level locking mechanism based on pg "advisory lock" feature. see https://www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key interface {
	Int64() int64
}

Key represents unique lock key

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

func New

func New(store *repository.Store) *Locker

func (*Locker) Do

func (l *Locker) Do(ctx context.Context, key Key, run func() error) error

Do acquires exclusive lock for provided resource

type RowKey

type RowKey struct {
	Table string
	ID    int64
}

func (RowKey) Int64

func (k RowKey) Int64() int64

type StringKey

type StringKey struct {
	Key string
}

func (StringKey) Int64

func (k StringKey) Int64() int64

Jump to

Keyboard shortcuts

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