Categorygithub.com/dynata/go-dbmutex
modulepackage
0.0.5
Repository: https://github.com/dynata/go-dbmutex.git
Documentation: pkg.go.dev

# README

go-dbmutex

Package dbmutex implements a DB-based mutex that can be used to synchronize work among multiple processes.

Features

  • works with mysql and postgres
  • should work with database failovers (haven't verified this)
  • mutex lock and unlock operations can timeout if desired
  • callers can be notified when mutexes are unlocked
  • minimal dependencies

Install

go get github.com/dynata/go-dbmutex

Documentation

PkgGoDev

Full godoc style documentation for the package can be viewed online without installing this package by using the GoDoc site.

Disclaimer

YOU ARE USING THIS APPLICATION AT YOUR OWN RISK. DYNATA MAKES NO WARRANTIES OR REPRESENTATIONS ABOUT THIS APPLICATION. THIS APPLICATION IS PROVIDED TO YOU “AS IS”. DYNATA HEREBY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED WITH RESPECT TO THE APPLICATION, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS OF PURPOSE, NON-INFRINGEMENT AND ANY IMPLIED WARRANTIES ARISING OUT OF A COURSE OF PERFORMANCE, DEALING, OR TRADE USAGE. TO THE EXTENT DYNATA MAY NOT, AS A MATTER OF APPLICABLE LAW, DISCLAIM ANY WARRANTY, THE SCOPE AND DURATION OF SUCH WARRANTY SHALL BE LIMITED TO THE MINIMUM PERMITTED UNDER SUCH APPLICABLE LAW. YOU WILL INDEMNIFY, DEFEND AND HOLD HARMLESS DYNATA AND ITS AFFILIATES, EMPLOYEES, OFFICERS AND CONTRACTORS FROM ANY THIRD PARTY CLAIM ARISING FROM YOUR USE OF THIS APPLICATION.

# Packages

No description provided by the author
No description provided by the author

# Functions

IgnoreLogError is an ErrorNotifier that does nothing with passed errors.
LogError is an ErrorNotifier that simply logs errors using the standard logger.
New creates a new Mutex.
NewMutexMap allocates a new MutexMap.
WithCreateMissingTable allows customization of table creation if it does not exist.
WithDelayAddMutexRow can be used to change the default (false) case for delaying the insertion of a row into the mutex table.
WithDelayCreateMissingTable allows customization of table creation if it does not exist.
WithDelayResolveDriver allows customization of driver.Driver resolution.
WithDriver allows explict setting of the Driver.
WithErrorNotifier allows customization of the ErrorNotifier that will be used when acquiring the lock, releasing the lock and refreshing the lock.
WithExpiration allows customization of the duration after which a lock will expire if it is not refreshed.
WithFailFast, when passed true, causes (Un)Lock calls to immediately return if unable to interact with the underlying database.
WithLockErrorNotifier allows customization of the ErrorNotifier that will be used when acquiring the lock in the Lock call.
WithMaxLocalWaiters sets the maximum number of local waiters.
WithMutexName uses name as the name of lock.
WithMutexOptions can be used to customize the Mutex objects that are used for locking.
WithMutexTableName allows customization of the lock table name.
WithPollInterval will change the interval at which (Un)Lock tries to acquire or release the lock.
WithRefresh allows customization of the interval at which lock refreshes are performed.
WithRefreshErrorNotifier allows customization of the ErrorNotifier that will be used when keeping the Mutex refreshed.
WithUnlockErrorNotifier allows customization of the ErrorNotifier that will be used when releasing the lock in the Unlock call.

# Constants

DefaultExpiration is the default time after which a mutex will expire if it has not been automatically refreshed.
DefaultMutexName is the default mutex name that will be used unless overridden via WithMutexName.
DefaultMutexTableName is the default table name that will be used for storing mutexes unless overridden via WithMutexTableName.
DefaultPollInterval is the default time that will be used to poll a locked mutex when attempting to lock a mutex.
DefaultRefresh is the default time to wait between refreshing locked Mutexes.

# Structs

An Identity uniquely identifies a Mutex.
A Mutex is used to provide mutual exclusion among multiple processes that have access to a shared database.
MutexMap implements a map of named mutexes.

# Type aliases

An ErrorNotifier is called to notify when an error occurs while locking, unlocking and refreshing Mutexes.
MutexMapOption is used to customize MutexMap behaviour.
MutexOption is used to customize Mutex behaviour.