private static IDbDistributedLock CreateInternalLock(string name, string connectionString, Action <MySqlConnectionOptionsBuilder>?options) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } var(keepaliveCadence, useMultiplexing) = MySqlConnectionOptionsBuilder.GetOptions(options); if (useMultiplexing) { return(new OptimisticConnectionMultiplexingDbDistributedLock(name, connectionString, MySqlMultiplexedConnectionLockPool.Instance, keepaliveCadence)); } return(new DedicatedConnectionOrTransactionDbDistributedLock(name, () => new MySqlDatabaseConnection(connectionString), useTransaction: false, keepaliveCadence)); }
internal static (TimeoutValue keepaliveCadence, bool useMultiplexing) GetOptions(Action <MySqlConnectionOptionsBuilder>?optionsBuilder) { MySqlConnectionOptionsBuilder?options; if (optionsBuilder != null) { options = new MySqlConnectionOptionsBuilder(); optionsBuilder(options); } else { options = null; } var keepaliveCadence = options?._keepaliveCadence ?? TimeSpan.FromHours(3.5); var useMultiplexing = options?._useMultiplexing ?? true; return(keepaliveCadence, useMultiplexing); }