Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrLockExists is returned from Lock() when the lock is already taken. ErrLockExists = errors.New("lock exists") // ErrNoLockExists is returned from Unlock() when the lock does not exist. ErrNoLockExists = errors.New("no lock exists") )
Functions ¶
func NewMiddleware ¶
func NewMiddleware(l Lock) eh.CommandHandlerMiddleware
NewMiddleware returns a new lock middle ware using a provided lock implementation. Useful for handling only one command per aggregate ID at a time.
Types ¶
type LocalLock ¶
type LocalLock struct {
// contains filtered or unexported fields
}
LocalLock is a Lock implemention using local locking only. Not suitable for use in distributed environments.
type Lock ¶
type Lock interface {
// Lock sets a lock for the ID. Returns ErrLockExists if the lock is already
// taken or another error if it was not possible to get the lock.
Lock(id string) error
// Unlock releases the lock for the ID. Returns ErrNoLockExists if there is
// no lock for the ID or another error if it was not possible to unlock.
Unlock(id string) error
}
Lock is a locker of IDs.
Click to show internal directories.
Click to hide internal directories.