Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DistributedLocker ¶
type DistributedLocker interface { // LockAcquired returns true if the lock is currently acquired. LockAcquired() bool // Try to acquire the lock. If the lock is already acquired return true and // a deadlock error. Try() (bool, error) // Unlock the lock. Unlock() error // ID returns the ID or lock path for this lock. ID() string // GetMember gets the member that currently has the lock for the provided ID, if it's currently // locked, otherwise return an empty string. GetMember(id string) (string, error) }
DistributedLocker is an interface for creating non-blocking locks among distributed processes.
func NewNonBlockingLock ¶
func NewNonBlockingLock(id string, member string) DistributedLocker
func NewZookeeperNonBlockingLock ¶
func NewZookeeperNonBlockingLock(conn *zk.Conn, id string, member string, acl []zk.ACL) DistributedLocker
NewZookeeperNonBlockingLock creates a new lock instance using the provided connection, path, and acl. The path must be a node that is only used by this lock. A lock instances starts unlocked until Try() is called.
type NonBlockingLock ¶
type NonBlockingLock struct {
// contains filtered or unexported fields
}
NonBlockingLock is an implementation of DistributedLocker that does NOT support multiple processes. NonBlockingLock is used for testing and documenting a reference implementation of DistributedLocker. Do not use this in production unless you have a clear understanding of how this works.
func (*NonBlockingLock) ID ¶
func (l *NonBlockingLock) ID() string
func (*NonBlockingLock) LockAcquired ¶ added in v0.12.0
func (l *NonBlockingLock) LockAcquired() bool
func (*NonBlockingLock) Try ¶
func (l *NonBlockingLock) Try() (bool, error)
func (*NonBlockingLock) Unlock ¶
func (l *NonBlockingLock) Unlock() error
type ZookeeperNonBlockingLock ¶
type ZookeeperNonBlockingLock struct {
// contains filtered or unexported fields
}
func (*ZookeeperNonBlockingLock) GetMember ¶
func (l *ZookeeperNonBlockingLock) GetMember(id string) (string, error)
func (*ZookeeperNonBlockingLock) ID ¶
func (l *ZookeeperNonBlockingLock) ID() string
func (*ZookeeperNonBlockingLock) LockAcquired ¶ added in v0.12.0
func (l *ZookeeperNonBlockingLock) LockAcquired() bool
func (*ZookeeperNonBlockingLock) Try ¶
func (l *ZookeeperNonBlockingLock) Try() (bool, error)
func (*ZookeeperNonBlockingLock) Unlock ¶
func (l *ZookeeperNonBlockingLock) Unlock() error
Unlock releases an acquired lock. If the lock is not currently acquired by this Lock instance than ErrNotLocked is returned. This should only be called if we're still connected.