示例#1
0
 /// <summary>
 /// Creates a new instance of the DistributedLock class.
 /// </summary>
 /// <param name="store">The object store where the object exists.</param>
 /// <param name="staleLockMultiplier">A multiplier used to determine if a previously locked object is stale. Setting this value too short will result in one lock overwriting another.</param>
 public DistributedLock(ISharpLockDataStore <TLockableObject, TId> store, int staleLockMultiplier = 10)
 {
     _store               = store ?? throw new ArgumentNullException(nameof(store));
     _sharpLockLogger     = _store.GetLogger();
     LockTime             = _store.GetLockTime();
     _staleLockMultiplier = staleLockMultiplier;
 }
 internal DistributedLock(ILogger logger, ISharpLockDataStore <TBaseObject, TLockableObject, TId> store, int staleLockMultiplier)
 {
     _store               = store ?? throw new ArgumentNullException(nameof(store));
     _logger              = logger;
     LockTime             = _store.GetLockTime();
     _staleLockMultiplier = staleLockMultiplier;
 }
 /// <summary>
 /// Creates a new instance of the DistributedLock class.
 /// </summary>
 /// <param name="store">The object store where the object exists.</param>
 /// <param name="fieldSelector">A LINQ expression giving the path to the <seealso cref="TLockableObject"/></param>
 /// <param name="staleLockMultiplier">A multiplier used to determine if a previously locked object is stale. Setting this value too short will result in one lock overwriting another.</param>
 public DistributedLock(ISharpLockDataStore <TBaseObject, TLockableObject, TId> store, Expression <Func <TBaseObject, IEnumerable <TLockableObject> > > fieldSelector, int staleLockMultiplier = 5)
     : this(store, staleLockMultiplier)
 {
     _tLockableObjectArrayFieldSelector = fieldSelector ?? throw new ArgumentNullException(nameof(fieldSelector));
 }
 /// <summary>
 /// Creates a new instance of the DistributedLock class.
 /// </summary>
 /// <param name="loggerFactory">A <see cref="ILoggerFactory"/> to obtain a <see cref="ILogger"/> for operation logging.</param>
 /// <param name="store">The object store where the object exists.</param>
 /// <param name="fieldSelector">A LINQ expression giving the path to the <seealso cref="TLockableObject"/></param>
 /// <param name="staleLockMultiplier">A multiplier used to determine if a previously locked object is stale. Setting this value too short will result in one lock overwriting another.</param>
 public DistributedLock(ILoggerFactory loggerFactory, ISharpLockDataStore <TBaseObject, TLockableObject, TId> store, Expression <Func <TBaseObject, TLockableObject> > fieldSelector, int staleLockMultiplier = 5)
     : this(loggerFactory.CreateLogger <DistributedLock <TBaseObject, TLockableObject, TId> >(), store, staleLockMultiplier)
 {
     _tLockableObjectFieldSelector = fieldSelector ?? throw new ArgumentNullException(nameof(fieldSelector));
 }
示例#5
0
 /// <summary>
 /// Creates a new instance of the DistributedLock class.
 /// </summary>
 /// <param name="loggerFactory">A <see cref="ILoggerFactory"/> to obtain a <see cref="ILogger"/> for operation logging.</param>
 /// <param name="store">The object store where the object exists.</param>
 /// <param name="staleLockMultiplier">A multiplier used to determine if a previously locked object is stale. Setting this value too short will result in one lock overwriting another.</param>
 public DistributedLock(ILoggerFactory loggerFactory, ISharpLockDataStore <TLockableObject, TId> store, int staleLockMultiplier = 10)
     : this(loggerFactory.CreateLogger <DistributedLock <TLockableObject, TId> >(), store, staleLockMultiplier)
 {
 }
示例#6
0
 /// <summary>
 /// Creates a new instance of the DistributedLock class.
 /// </summary>
 /// <param name="store">The object store where the object exists.</param>
 /// <param name="staleLockMultiplier">A multiplier used to determine if a previously locked object is stale. Setting this value too short will result in one lock overwriting another.</param>
 public DistributedLock(ISharpLockDataStore <TLockableObject, TId> store, int staleLockMultiplier = 10)
     : this(store.GetLogger(), store, staleLockMultiplier)
 {
 }