Class EntityFrameworkLock
- Namespace
- Silverback.Lock
- Assembly
- Silverback.Storage.EntityFramework.dll
The distributed lock based on a PostgreSql table.
public class EntityFrameworkLock : TableBasedDistributedLock, IDistributedLock
- Inheritance
-
EntityFrameworkLock
- Implements
- Inherited Members
Constructors
EntityFrameworkLock(EntityFrameworkLockSettings, IServiceScopeFactory, ISilverbackLogger<EntityFrameworkLock>)
Initializes a new instance of the EntityFrameworkLock class.
public EntityFrameworkLock(EntityFrameworkLockSettings settings, IServiceScopeFactory serviceScopeFactory, ISilverbackLogger<EntityFrameworkLock> logger)
Parameters
settingsEntityFrameworkLockSettingsThe lock settings.
serviceScopeFactoryIServiceScopeFactoryThe IServiceScopeFactory.
loggerISilverbackLogger<EntityFrameworkLock>The logger.
Methods
ReleaseLockAsync(string)
Releases the lock.
protected override Task ReleaseLockAsync(string handlerName)
Parameters
handlerNamestringThe name of the current handler.
Returns
TryAcquireLockAsync(string)
Tries to acquire the lock.
protected override 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 override Task UpdateHeartbeatAsync(string handlerName)
Parameters
handlerNamestringThe name of the current handler.