Table of Contents

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

settings TableBasedDistributedLockSettings

The lock settings.

logger ISilverbackLogger<TableBasedDistributedLock>

The logger.

Methods

AcquireCoreAsync(CancellationToken)

Acquires the lock.

protected override ValueTask<DistributedLockHandle> AcquireCoreAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A 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

handlerName string

The name of the current handler.

Returns

Task

A Task representing the asynchronous operation.

TryAcquireLockAsync(string)

Tries to acquire the lock.

protected abstract Task<bool> TryAcquireLockAsync(string handlerName)

Parameters

handlerName string

The name of the current handler.

Returns

Task<bool>

A Task representing the asynchronous operation. The result is true if the lock was acquired, otherwise false.

UpdateHeartbeatAsync(string)

Updates the last heartbeat of the lock.

protected abstract Task UpdateHeartbeatAsync(string handlerName)

Parameters

handlerName string

The name of the current handler.

Returns

Task

A Task representing the asynchronous operation.