private MySqlDistributedLock(string name, bool exactName, Func <string, IDbDistributedLock> internalLockFactory) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (exactName) { if (name.Length > MaxNameLength) { throw new FormatException($"{nameof(name)}: must be at most {MaxNameLength} characters"); } if (name.Length == 0) { throw new FormatException($"{nameof(name)}: must not be empty"); } if (name.ToLowerInvariant() != name) { throw new FormatException($"{nameof(name)}: must not container uppercase letters"); } this.Name = name; } else { this.Name = GetSafeName(name); } this._internalLock = internalLockFactory(this.Name); }
private SqlDistributedSemaphore(string name, int maxCount, Func <string, IDbDistributedLock> createInternalLockFromName) { if (maxCount < 1) { throw new ArgumentOutOfRangeException(nameof(maxCount), maxCount, "must be positive"); } this.Name = name ?? throw new ArgumentNullException(nameof(name)); this._strategy = new SqlSemaphore(maxCount); this._internalLock = createInternalLockFromName(SqlSemaphore.ToSafeName(name)); }
public OptimisticConnectionMultiplexingDbDistributedLock( string name, string connectionString, MultiplexedConnectionLockPool multiplexedConnectionLockPool, TimeoutValue keepaliveCadence) { this._name = name; this._connectionString = connectionString; this._multiplexedConnectionLockPool = multiplexedConnectionLockPool; this._keepaliveCadence = keepaliveCadence; this._fallbackLock = new DedicatedConnectionOrTransactionDbDistributedLock( name, () => this._multiplexedConnectionLockPool.ConnectionFactory(this._connectionString), useTransaction: false, keepaliveCadence: keepaliveCadence ); }
private SqlDistributedReaderWriterLock(string name, bool exactName, Func <string, IDbDistributedLock> internalLockFactory) { if (exactName) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (name.Length > MaxNameLength) { throw new FormatException($"{nameof(name)}: must be at most {MaxNameLength} characters"); } this.Name = name; } else { this.Name = GetSafeName(name); } this._internalLock = internalLockFactory(this.Name); }
private OracleDistributedReaderWriterLock(string name, bool exactName, Func <string, IDbDistributedLock> internalLockFactory) { this.Name = OracleDistributedLock.GetName(name, exactName); this._internalLock = internalLockFactory(this.Name); }
private PostgresDistributedLock(PostgresAdvisoryLockKey key, IDbDistributedLock internalLock) { this.Key = key; this._internalLock = internalLock; }