Class TableBasedDistributedLock
- Namespace
- Silverback.Lock
- Assembly
- Silverback.Storage.Relational.dll
The base class for the table-based locks.
public abstract class TableBasedDistributedLock : DistributedLock, IDistributedLock
- Inheritance
-
TableBasedDistributedLock
- Implements
- Derived
- Inherited Members
Constructors
TableBasedDistributedLock(TableBasedDistributedLockSettings, ISilverbackLogger<TableBasedDistributedLock>)
Initializes a new instance of the TableBasedDistributedLock class.
protected TableBasedDistributedLock(TableBasedDistributedLockSettings settings, ISilverbackLogger<TableBasedDistributedLock> logger)
Parameters
settingsTableBasedDistributedLockSettingsThe lock settings.
loggerISilverbackLogger<TableBasedDistributedLock>The logger.
Methods
AcquireCoreAsync(CancellationToken)
Acquires the lock.
protected override ValueTask<DistributedLockHandle> AcquireCoreAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA CancellationToken used to cancel the operation.
Returns
- ValueTask<DistributedLockHandle>
A Task representing the asynchronous operation.
ReleaseLockAsync(string)
Releases the lock.
protected abstract Task ReleaseLockAsync(string handlerName)
Parameters
handlerNamestringThe name of the current handler.
Returns
TryAcquireLockAsync(string)
Tries to acquire the lock.
protected abstract Task<bool> TryAcquireLockAsync(string handlerName)
Parameters
handlerNamestringThe name of the current handler.
Returns
- Task<bool>
A Task representing the asynchronous operation. The result is
trueif the lock was acquired, otherwisefalse.
UpdateHeartbeatAsync(string)
Updates the last heartbeat of the lock.
protected abstract Task UpdateHeartbeatAsync(string handlerName)
Parameters
handlerNamestringThe name of the current handler.