lock

package
v1.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package lock provides distributed lock interface.

Implementations include:
  * MySQL GET_LOCK() based distributed locking

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

type Lock interface {
	// Try to acquire a lock. Returns false if failed.
	TryLock(s string) bool
	// Try to acquire a lock. Returns false if failed.
	// Allows n simultaneous locks to be held
	TryLockShared(s string, n int) bool

	// Try to acquire a lock and wait for specified period of time for the lock
	// to become available. Returns false if failed.
	Lock(s string, waitDuration time.Duration) bool

	// Check if we still have the lock. Try to reacquire if necessary.
	// Returns false in the case of failure
	Refresh() bool

	// Unlock the lock. Returns false if there was failure
	Unlock() bool

	//Close releases resources associated with the lock
	Close() bool
}

Lock is general distributed lock interface

func Create

func Create(ci *db.Addr) Lock

Create an instance of Lock ntickets - is concurrency allowed for the lock, meaning n processes can hold the lock at the same time

Jump to

Keyboard shortcuts

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