Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions RedLockNet.SERedis/RedLockFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class RedLockFactory : IDistributedLockFactory, IDisposable
private readonly RedLockConfiguration configuration;
private readonly ILoggerFactory loggerFactory;
private readonly ICollection<RedisConnection> redisCaches;
private readonly ILogger<RedLock> redlockLogger;

public event EventHandler<RedLockConfigurationChangedEventArgs> ConfigurationChanged;

Expand Down Expand Up @@ -72,8 +73,9 @@ public RedLockFactory(RedLockConfiguration configuration)
this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration), "Configuration must not be null");
this.loggerFactory = configuration.LoggerFactory ?? new LoggerFactory();
this.redisCaches = configuration.ConnectionProvider.CreateRedisConnections();
this.redlockLogger = loggerFactory.CreateLogger<RedLock>();

SubscribeToConnectionEvents();
SubscribeToConnectionEvents();
}

private void SubscribeToConnectionEvents()
Expand All @@ -100,7 +102,7 @@ private void MultiplexerConfigurationChanged(object sender, StackExchange.Redis.
public IRedLock CreateLock(string resource, TimeSpan expiryTime)
{
return RedLock.Create(
this.loggerFactory.CreateLogger<RedLock>(),
redlockLogger,
redisCaches,
resource,
expiryTime,
Expand All @@ -110,7 +112,7 @@ public IRedLock CreateLock(string resource, TimeSpan expiryTime)
public async Task<IRedLock> CreateLockAsync(string resource, TimeSpan expiryTime)
{
return await RedLock.CreateAsync(
this.loggerFactory.CreateLogger<RedLock>(),
redlockLogger,
redisCaches,
resource,
expiryTime,
Expand All @@ -120,7 +122,7 @@ public async Task<IRedLock> CreateLockAsync(string resource, TimeSpan expiryTime
public IRedLock CreateLock(string resource, TimeSpan expiryTime, TimeSpan waitTime, TimeSpan retryTime, CancellationToken? cancellationToken = null)
{
return RedLock.Create(
this.loggerFactory.CreateLogger<RedLock>(),
redlockLogger,
redisCaches,
resource,
expiryTime,
Expand All @@ -133,7 +135,7 @@ public IRedLock CreateLock(string resource, TimeSpan expiryTime, TimeSpan waitTi
public async Task<IRedLock> CreateLockAsync(string resource, TimeSpan expiryTime, TimeSpan waitTime, TimeSpan retryTime, CancellationToken? cancellationToken = null)
{
return await RedLock.CreateAsync(
this.loggerFactory.CreateLogger<RedLock>(),
redlockLogger,
redisCaches,
resource,
expiryTime,
Expand Down