Table of Contents

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

settings EntityFrameworkLockSettings

The lock settings.

serviceScopeFactory IServiceScopeFactory

The IServiceScopeFactory.

logger ISilverbackLogger<EntityFrameworkLock>

The logger.

Methods

ReleaseLockAsync(string)

Releases the lock.

protected override 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 override 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 override Task UpdateHeartbeatAsync(string handlerName)

Parameters

handlerName string

The name of the current handler.

Returns

Task

A Task representing the asynchronous operation.