Ejemplo n.º 1
0
 public ColidLock(string resource, string lockId, bool isAcquired, RedLockStatus status, RedLockInstanceSummary instanceSummary, int extendCount, Action <string> disposeAction)
 {
     Resource        = resource;
     LockId          = lockId;
     IsAcquired      = isAcquired;
     Status          = status;
     InstanceSummary = instanceSummary;
     ExtendCount     = extendCount;
     _disposeAction  = disposeAction;
 }
Ejemplo n.º 2
0
 public ColidLockBuilder WithStatus(RedLockStatus status)
 {
     _lock.Status = status;
     return(this);
 }
Ejemplo n.º 3
0
        private static void CheckSingleRedisLock([InstantHandle] Func <RedLockFactory> factoryBuilder, RedLockStatus expectedStatus)
        {
            using (var redisLockFactory = factoryBuilder())
            {
                var resource = $"testredislock:{Guid.NewGuid()}";

                using (var redisLock = redisLockFactory.CreateLock(resource, TimeSpan.FromSeconds(30)))
                {
                    Assert.That(redisLock.IsAcquired, Is.EqualTo(expectedStatus == RedLockStatus.Acquired));
                    Assert.That(redisLock.Status, Is.EqualTo(expectedStatus));
                }
            }
        }
Ejemplo n.º 4
0
 private static DistributedLockBadStatus RedLockStatusToDistributedLockBadStatus(RedLockStatus redLockStatus)
 {
     return(redLockStatus switch
     {
         RedLockStatus.Unlocked => DistributedLockBadStatus.Unlocked,
         RedLockStatus.Conflicted => DistributedLockBadStatus.Conflicted,
         RedLockStatus.Expired => DistributedLockBadStatus.Expired,
         RedLockStatus.NoQuorum => DistributedLockBadStatus.NoQuorum,
         _ => throw new ArgumentOutOfRangeException()
     });