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