mutex

package
v1.5.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ProdMutexPrefix = "/gromit/prod/"

ProdMutexPrefix is the prefix for all the created mutex objects.

View Source
const TestMutexPrefix = "/gromit/test/"

TestMutexPrefix should only be used from within unit and integration tests.

Variables

This section is empty.

Functions

func GetEtcdClient

func GetEtcdClient(host string, timeout time.Duration, user string, pass string) (*clientv3.Client, error)

GetEtcdClient creates an etcd client.

func GetEtcdTLSClient

func GetEtcdTLSClient(host string, tls *tls.Config, timeout time.Duration) (*clientv3.Client, error)

func GetMutex

func GetMutex(session *concurrency.Session, prefix string) *concurrency.Mutex

func GetSession

func GetSession(client *clientv3.Client) (*concurrency.Session, error)

Types

type Lock

type Lock struct {
	Client  *clientv3.Client
	Session *concurrency.Session
	Mutex   *concurrency.Mutex
}

func (*Lock) Close

func (e *Lock) Close() error

Close releases the client and session resources

func (*Lock) Release

func (e *Lock) Release() error

Release an existent lock

func (*Lock) TryAcquire

func (e *Lock) TryAcquire() error

Try to adquire a lock (non-blocking), if process is locked will log error and exit without locking

Jump to

Keyboard shortcuts

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