Documentation ¶
Overview ¶
Package concurrency provides support for distributed concurrency capabilities
The goal is to simplify the development of concurrency capabilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EtcdMutex ¶
type EtcdMutex struct {
// contains filtered or unexported fields
}
EtcdMutex implements a distributed lock based on etcd.
func NewEtcdMutex ¶
NewEtcdMutex new a mutex for a etcd implementation.
type Mutex ¶
type Mutex interface { // Lock get lock through chain id and sequence // // If it returned an error, indicates that the call failed. // Whether successful or not, // the current sequence saved in the distributed lock is returned. // Negative sequence(<0) are returned unless there are some unknown exceptions. Lock(sequence int64) (int64, error) // Update update the sequence saved in the distributed lock. Update(sequence int64) error // Unlock after successfully acquiring the lock, the lock needs to be unlocked. // // If it returned an error, indicates that the call failed. Unlock(success bool) error // Close close the lock Close() error }
Mutex distributed lock interface
type StandaloneMutex ¶
type StandaloneMutex struct {
// contains filtered or unexported fields
}
StandaloneMutex implements a standalone version for single process.
func NewStandaloneMutex ¶
func NewStandaloneMutex(name string) *StandaloneMutex
NewStandaloneMutex new a mutex for a standalone implementation.
func (*StandaloneMutex) Lock ¶
func (s *StandaloneMutex) Lock(sequence int64) (int64, error)
Lock get lock
func (*StandaloneMutex) Unlock ¶
func (s *StandaloneMutex) Unlock(success bool) error
Unlock unlock the lock
func (*StandaloneMutex) Update ¶
func (s *StandaloneMutex) Update(sequence int64) error
Update update the sequence in lock
Click to show internal directories.
Click to hide internal directories.