Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DLock ¶
type DLock interface { Acquire() Release() }
DLock constrains the methods a real distributed lock should implement.
type FastDLock ¶
type FastDLock struct {
// contains filtered or unexported fields
}
FastDLock implements the distributed lock using zookeeper.
func NewFastDLock ¶
func NewFastDLock() *FastDLock
NewFastDLock creates a FastDLock instance.
==> acquire lock n = create("/zklock/fast-lock/request-", "", empheral|sequential) retry:
requests = getChildren("/zklock/fast-lock", false) if n is lowest znode in requests: return else: exists("/zklock/fast-lock/request-" % n - 1, watch = True)
watch_event:
goto retry
==> release lock (voluntarily or session timeout) delete("/zklock/fast-lock/request-" % n)
type SlowDLock ¶
type SlowDLock struct { }
SlowDLock implements the distributed lock using zookeeper.
func NewSlowDLock ¶
func NewSlowDLock() *SlowDLock
NewSlowDLock creates a SlowDLock instance.
==> acquire lock retry:
r = create("/zklock/slow-lock", "", empheral) if r: return else: exist("/zklock/slow-lock", watch=True)
watch_event:
goto retry
==> release lock (voluntarily or session timeout) delete("/zklock/slow-lock")
Click to show internal directories.
Click to hide internal directories.