Documentation ¶
Overview ¶
Package ytlock is high level interface for yt lock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLockLost = xerrors.NewSentinel("lock lost")
ErrLockLost is an error propagated to notify in RunLocked when an acquired lock is lost.
Functions ¶
func AbortExclusiveLock ¶
AbortExclusiveLock cancels transaction under exclusive lock specified by the path.
There can not be more than one exclusive lock acquired for the path at the time.
In case if node has not acquired an exclusive lock nil is returned.
func RunLocked ¶ added in v0.0.15
RunLocked infinitely (with constant back-off) reacquires the lock and reruns the job.
Stops when the job finishes with no error or when the context is closed.
Calls notify on each failed attempt. In case of lost lock notify will have an error that wraps ErrLockLost.
Types ¶
type Lock ¶
type Lock struct { Path ypath.Path Options Options Yc yt.Client // contains filtered or unexported fields }
Lock object represents cypress lock.
func NewLockOptions ¶
NewLockOptions creates Lock object with specified options.
func (*Lock) Acquire ¶
Acquire acquires cypress lock.
Returned lost channel is closed when lock is lost because of some external event, e.g. transaction being aborted remotely, network partition or coordination service downtime.
If lock is lost, there is no need to call Release explicitly.
Lock is automatically released when provided ctx is canceled.
func (*Lock) AcquireTx ¶
AcquireTx is the same as Acquire, but returns new tx that is holding the lock.
type Notify ¶ added in v0.0.15
Notify is a notify-on-error function.
It receives a job error and backoff delay if the job failed.