Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ILock

Hierarchy

Implemented by

Index

Methods

destroy

  • destroy(): Promise<void>

forceUnlock

  • forceUnlock(): Promise<void>
  • Forcefully unlocks the lock. Usually, the same client has to call unlock the same amount of times as the amount of times it has called lock, otherwise the lock will remain in locked state. This method will disregard the acquire count and release this lock immediately.

    Returns Promise<void>

getLockCount

  • getLockCount(): Promise<number>
  • Returns Promise<number>

    the number of times this lock was acquired by its owner, i.e. how many times the unlock method should be invoked for the lock to become free.

getName

  • getName(): string

getPartitionKey

  • getPartitionKey(): string

getRemainingLeaseTime

  • getRemainingLeaseTime(): Promise<number>
  • Returns Promise<number>

    the number of milliseconds in which the lease for this lock will expire.

getServiceName

  • getServiceName(): string

isLocked

  • isLocked(): Promise<boolean>
  • Returns Promise<boolean>

    true if this lock is currently in the locked state, false otherwise.

isLockedByThisClient

  • isLockedByThisClient(): Promise<boolean>
  • Returns Promise<boolean>

    true if this lock is currently held by this client, false otherwise.

lock

  • lock(leaseMillis?: number): Promise<void>
  • Acquires this lock, waiting indefinitely for it to become available. The returned promise will be resolved as soon as this lock is acquired. If lease time is specified then this lock will be held for the specified amount of time and then released automatically. Otherwise it will be held indefinitely up until the user invokes unlock.

    Parameters

    • Optional leaseMillis: number

      period of time in milliseconds for which this lock should be held.

    Returns Promise<void>

tryLock

  • tryLock(timeoutMillis?: number, leaseMillis?: number): Promise<boolean>
  • Tries to acquire this lock within a specified timeout. The returned promise will be resolved either when this lock is acquired or when timeout is reached. Setting timeout to -1 will make this method wait for the lock availability indefinitely. If lease time is specified then this lock will be held for the specified amount of time and then released automatically. Otherwise it will be held indefinitely up until the user invokes unlock.

    Parameters

    • Optional timeoutMillis: number

      period of time in milliseconds to wait for this lock to become available.

    • Optional leaseMillis: number

      period of time in milliseconds for which this lock should be held.

    Returns Promise<boolean>

    true if this lock was obtained in the specified time period, false otherwise.

unlock

  • unlock(): Promise<void>

Generated using TypeDoc