Module eetcd_lock

Function Index

lock/1Lock acquires a distributed shared lock on a given named lock.
lock/3
new/1Creates a blank context for a request.
unlock/2Unlock takes a key returned by Lock and releases the hold on lock.
with_key/2key is a key that will exist on etcd for the duration that the Lock caller owns the lock.
with_lease/2lease is the ID of the lease that will be attached to ownership of the lock.
with_name/2name is the identifier for the distributed shared lock to be acquired.
with_timeout/2Timeout is an integer greater than zero which specifies how many milliseconds to wait for a reply, or the atom infinity to wait indefinitely.

Function Details

lock/1

lock(Ctx::context()) -> {ok, router_pb:'Etcd.LockResponse'()} | {error, eetcd_error()}

Lock acquires a distributed shared lock on a given named lock. On success, it will return a unique key that exists so long as the lock is held by the caller. This key can be used in conjunction with transactions to safely ensure updates to etcd only occur while holding lock ownership. The lock is held until Unlock is called on the key or the lease associate with the owner expires.

lock/3

lock(Ctx::context() | name(), Name::binary(), LeaseID::pos_integer()) -> {ok, router_pb:'Etcd.LockResponse'()} | {error, eetcd_error()}

new/1

new(Context::atom() | reference()) -> context()

Creates a blank context for a request.

unlock/2

unlock(Ctx::context() | name(), Key::binary()) -> {ok, router_pb:'Etcd.UnlockRequest'()} | {error, eetcd_error()}

Unlock takes a key returned by Lock and releases the hold on lock. The next Lock caller waiting for the lock will then be woken up and given ownership of the lock.

with_key/2

with_key(Context::context(), Key::binary()) -> context()

key is a key that will exist on etcd for the duration that the Lock caller owns the lock. Users should not modify this key or the lock may exhibit undefined behavior.

with_lease/2

with_lease(Context::context(), LeaseID::pos_integer()) -> context()

lease is the ID of the lease that will be attached to ownership of the lock. If the lease expires or is revoked and currently holds the lock, the lock is automatically released. Calls to Lock with the same lease will be treated as a single acquisition; locking twice with the same lease is a no-op.

with_name/2

with_name(Context::context(), Name::binary()) -> context()

name is the identifier for the distributed shared lock to be acquired.

with_timeout/2

with_timeout(Context::context(), Timeout::pos_integer() | infinity) -> context()

Timeout is an integer greater than zero which specifies how many milliseconds to wait for a reply, or the atom infinity to wait indefinitely. If no reply is received within the specified time, the function call fails with {error, timeout}.


Generated by EDoc