internal static IDbDistributedLock CreateInternalLock(PostgresAdvisoryLockKey key, string connectionString, Action <PostgresConnectionOptionsBuilder>?options)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            var(keepaliveCadence, useMultiplexing) = PostgresConnectionOptionsBuilder.GetOptions(options);

            if (useMultiplexing)
            {
                return(new OptimisticConnectionMultiplexingDbDistributedLock(key.ToString(), connectionString, PostgresMultiplexedConnectionLockPool.Instance, keepaliveCadence));
            }

            return(new DedicatedConnectionOrTransactionDbDistributedLock(key.ToString(), () => new PostgresDatabaseConnection(connectionString), useTransaction: false, keepaliveCadence));
        }
 internal static IDbDistributedLock CreateInternalLock(PostgresAdvisoryLockKey key, IDbConnection connection)
 {
     if (connection == null)
     {
         throw new ArgumentNullException(nameof(connection));
     }
     return(new DedicatedConnectionOrTransactionDbDistributedLock(key.ToString(), () => new PostgresDatabaseConnection(connection)));
 }