Added retry policy for sleeping serverless error for SqlConnections (#2155)

This commit is contained in:
Alex Ma
2023-08-16 13:17:40 -07:00
committed by GitHub
parent e4db70fb39
commit 4ae9534ac8
15 changed files with 140 additions and 63 deletions

View File

@@ -7,6 +7,7 @@
using System.Data.Common;
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
using Microsoft.Data.SqlClient;
namespace Microsoft.SqlTools.ServiceLayer.Connection
{
@@ -20,11 +21,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
/// <summary>
/// Creates a new SqlConnection object
/// </summary>
public DbConnection CreateSqlConnection(string connectionString, string azureAccountToken)
/// <param name="retryProvider">Optional retry provider to handle errors in a special way</param>
public DbConnection CreateSqlConnection(string connectionString, string azureAccountToken, SqlRetryLogicBaseProvider retryProvider = null)
{
RetryPolicy connectionRetryPolicy = RetryPolicyFactory.CreateDefaultConnectionRetryPolicy();
RetryPolicy commandRetryPolicy = RetryPolicyFactory.CreateDefaultConnectionRetryPolicy();
return new ReliableSqlConnection(connectionString, connectionRetryPolicy, commandRetryPolicy, azureAccountToken);
return new ReliableSqlConnection(connectionString, connectionRetryPolicy, commandRetryPolicy, azureAccountToken, retryProvider);
}
}
}