Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
83cee90
Code changes to add regional endpoints for account metadata calls.
kundadebdatta Jan 17, 2024
1e12015
Code changes to refactor some codes.
kundadebdatta Jan 19, 2024
7f68b28
Code changes to add unit tests.
kundadebdatta Jan 22, 2024
7aa43f8
Code changes to make minor code clean-up.
kundadebdatta Jan 23, 2024
58517ed
Merge branch 'master' into users/kundadebdatta/4236_add_custom_domain…
kundadebdatta Jan 23, 2024
60a0803
Code changes to fix tests. Refactored API.
kundadebdatta Jan 23, 2024
a3b4c78
Merge branch 'users/kundadebdatta/4236_add_custom_domain_names' of ht…
kundadebdatta Jan 23, 2024
6efe507
Code changes to refactor the enumeration logic inside global endpoint…
kundadebdatta Jan 25, 2024
fb5af02
Code changes to address review comments.
kundadebdatta Jan 25, 2024
55f1ace
Code changes to fix minor API parameter.
kundadebdatta Jan 25, 2024
94b0058
Code changes to update the API naming.
kundadebdatta Jan 26, 2024
9cc57ad
Code changes to update some attribute names.
kundadebdatta Jan 26, 2024
3c4498f
Merge branch 'master' into users/kundadebdatta/4236_add_custom_domain…
kundadebdatta Jan 26, 2024
348e4a7
Code changes to refactor service endpoint creation logic.
kundadebdatta Jan 29, 2024
ea51744
Code changes to address review comments.
kundadebdatta Jan 30, 2024
b8788d4
Merge branch 'master' into users/kundadebdatta/4236_add_custom_domain…
kundadebdatta Jan 30, 2024
f177371
Code changes to address review comments.
kundadebdatta Feb 6, 2024
35d1c9a
Merge branch 'master' into users/kundadebdatta/4236_add_custom_domain…
kundadebdatta Feb 6, 2024
d4c3526
Code changes to update the API contract.
kundadebdatta Feb 6, 2024
5a39ba3
Merge branch 'master' into users/kundadebdatta/4236_add_custom_domain…
kundadebdatta Feb 6, 2024
65b9b44
Cosmetic code changes.
kundadebdatta Feb 6, 2024
be9b5d7
Merge branch 'master' into users/kundadebdatta/4236_add_custom_domain…
kundadebdatta Feb 7, 2024
3a9d168
Code changes to address review comments.
kundadebdatta Feb 8, 2024
581c6af
Merge branch 'master' into users/kundadebdatta/4236_add_custom_domain…
kundadebdatta Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code changes to address review comments.
  • Loading branch information
kundadebdatta committed Jan 30, 2024
commit ea51744c7c21d56e1df2989e24a4f325d33ddd60
14 changes: 7 additions & 7 deletions Microsoft.Azure.Cosmos/src/ConnectionPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal sealed class ConnectionPolicy

private Protocol connectionProtocol;
private ObservableCollection<string> preferredLocations;
private ObservableCollection<string> customPrivateEndpoints;
private ObservableCollection<string> accountInitializationCustomEndpoints;

/// <summary>
/// Initializes a new instance of the <see cref="ConnectionPolicy"/> class to connect to the Azure Cosmos DB service.
Expand All @@ -44,7 +44,7 @@ public ConnectionPolicy()
this.MediaReadMode = MediaReadMode.Buffered;
this.UserAgentContainer = new UserAgentContainer(clientId: 0);
this.preferredLocations = new ObservableCollection<string>();
this.customPrivateEndpoints = new ObservableCollection<string>();
this.accountInitializationCustomEndpoints = new ObservableCollection<string>();
this.EnableEndpointDiscovery = true;
this.MaxConnectionLimit = defaultMaxConcurrentConnectionLimit;
this.RetryOptions = new RetryOptions();
Expand Down Expand Up @@ -98,18 +98,18 @@ public void SetPreferredLocations(IReadOnlyList<string> regions)
/// </summary>
/// <param name="customEndpoints">An instance of <see cref="IEnumerable{T}"/> containing the custom DNS endpoints
/// provided by the customer.</param>
public void SetCustomEndpoints(
public void SetAccountInitializationCustomEndpoints(
IEnumerable<string> customEndpoints)
{
if (customEndpoints == null)
{
throw new ArgumentNullException(nameof(customEndpoints));
}

this.customPrivateEndpoints.Clear();
this.accountInitializationCustomEndpoints.Clear();
foreach (string endpoint in customEndpoints)
{
this.customPrivateEndpoints.Add(endpoint);
this.accountInitializationCustomEndpoints.Add(endpoint);
}
}

Expand Down Expand Up @@ -303,11 +303,11 @@ public Collection<string> PreferredLocations
/// provided in the customAccountEndpoints list.
/// </para>
/// </remarks>
public Collection<string> CustomPrivateEndpoints
public Collection<string> AccountInitializationCustomEndpoints
{
get
{
return this.customPrivateEndpoints;
return this.accountInitializationCustomEndpoints;
}
}

Expand Down
6 changes: 3 additions & 3 deletions Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ public string ApplicationName
public IReadOnlyList<string> ApplicationPreferredRegions { get; set; }

/// <summary>
/// Gets and sets the custom private endpoints for geo-replicated database accounts in the Azure Cosmos DB service.
/// Gets and sets the custom endpoints to use for account initialization for geo-replicated database accounts in the Azure Cosmos DB service.
/// </summary>
/// <remarks>
/// <para>
/// During the CosmosClient initialization the account information, including the available regions, is obtained from the <see cref="CosmosClient.Endpoint"/>.
/// Should the global endpoint become inaccessible, the CosmosClient will attempt to obtain the account information issuing requests to the custom endpoints provided in <see cref="AccountInitializationCustomEndpoints"/>.
/// </para>
/// <para>
/// Nevertheless, this parameter remains optional and is recommended for implementation when a customer has configured a private endpoint with a custom DNS hostname
/// Nevertheless, this parameter remains optional and is recommended for implementation when a customer has configured an endpoint with a custom DNS hostname
/// (instead of accountname-region.documents.azure.com) etc. for their Cosmos DB account.
/// </para>
/// <para>
Expand Down Expand Up @@ -833,7 +833,7 @@ internal virtual ConnectionPolicy GetConnectionPolicy(int clientId)

if (this.AccountInitializationCustomEndpoints != null)
{
connectionPolicy.SetCustomEndpoints(this.AccountInitializationCustomEndpoints);
connectionPolicy.SetAccountInitializationCustomEndpoints(this.AccountInitializationCustomEndpoints);
}

if (this.MaxRetryAttemptsOnRateLimitedRequests != null)
Expand Down
4 changes: 2 additions & 2 deletions Microsoft.Azure.Cosmos/src/Fluent/CosmosClientBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ public CosmosClientBuilder WithApplicationPreferredRegions(IReadOnlyList<string>
}

/// <summary>
/// Sets the custom private endpoints for geo-replicated database accounts in the Azure Cosmos DB service.
/// Sets the custom endpoints to use for account initialization for geo-replicated database accounts in the Azure Cosmos DB service.
/// During the CosmosClient initialization the account information, including the available regions, is obtained from the <see cref="CosmosClient.Endpoint"/>.
/// Should the global endpoint become inaccessible, the CosmosClient will attempt to obtain the account information issuing requests to the custom endpoints
/// provided in the customAccountEndpoints list.
/// </summary>
/// <param name="customAccountEndpoints">An instance of <see cref="IEnumerable{T}"/> of string containing the custom private endpoints for the cosmos db account.</param>
/// <remarks>
/// This function is optional and is recommended for implementation when a customer has configured one or more private endpoints with a custom DNS
/// This function is optional and is recommended for implementation when a customer has configured one or more endpoints with a custom DNS
/// hostname (instead of accountname-region.documents.azure.com) etc. for their Cosmos DB account.
/// </remarks>
/// <example>
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/GatewayAccountReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task<AccountProperties> InitializeReaderAsync()
AccountProperties databaseAccount = await GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(
defaultEndpoint: this.serviceEndpoint,
locations: this.connectionPolicy.PreferredLocations,
customPrivateEndpoints: this.connectionPolicy.CustomPrivateEndpoints,
accountInitializationCustomEndpoints: this.connectionPolicy.AccountInitializationCustomEndpoints,
getDatabaseAccountFn: this.GetDatabaseAccountAsync,
cancellationToken: this.cancellationToken);

Expand Down
20 changes: 10 additions & 10 deletions Microsoft.Azure.Cosmos/src/Routing/GlobalEndpointManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ public Uri GetHubUri()
public static async Task<AccountProperties> GetDatabaseAccountFromAnyLocationsAsync(
Uri defaultEndpoint,
IList<string>? locations,
IList<string> customPrivateEndpoints,
IList<string> accountInitializationCustomEndpoints,
Func<Uri, Task<AccountProperties>> getDatabaseAccountFn,
CancellationToken cancellationToken)
{
using (GetAccountPropertiesHelper threadSafeGetAccountHelper = new GetAccountPropertiesHelper(
defaultEndpoint,
locations,
customPrivateEndpoints,
accountInitializationCustomEndpoints,
getDatabaseAccountFn,
cancellationToken))
{
Expand All @@ -150,7 +150,7 @@ private class GetAccountPropertiesHelper : IDisposable
public GetAccountPropertiesHelper(
Uri defaultEndpoint,
IList<string>? locations,
IList<string> customPrivateEndpoints,
IList<string> accountInitializationCustomEndpoints,
Func<Uri, Task<AccountProperties>> getDatabaseAccountFn,
CancellationToken cancellationToken)
{
Expand All @@ -161,7 +161,7 @@ public GetAccountPropertiesHelper(
this.ServiceEndpointEnumerator = GetAccountPropertiesHelper.GetServiceEndpointEnumerator(
defaultEndpoint,
locations,
customPrivateEndpoints);
accountInitializationCustomEndpoints);
}

public async Task<AccountProperties> GetAccountPropertiesAsync()
Expand Down Expand Up @@ -336,20 +336,20 @@ private static bool IsNonRetriableException(Exception exception)
/// </summary>
/// <param name="defaultEndpoint">An instance of <see cref="Uri"/> containing the default global endpoint.</param>
/// <param name="locations">An instance of <see cref="IList{T}"/> containing the preferred location names.</param>
/// <param name="customPrivateEndpoints">An instance of <see cref="IList{T}"/> containing the private endpoints.</param>
/// <param name="accountInitializationCustomEndpoints">An instance of <see cref="IList{T}"/> containing the custom private endpoints.</param>
/// <returns>An instance of <see cref="IEnumerator{T}"/> containing the service endpoints.</returns>
private static IEnumerator<Uri> GetServiceEndpointEnumerator(
Uri defaultEndpoint,
IList<string>? locations,
IList<string> customPrivateEndpoints)
IList<string> accountInitializationCustomEndpoints)
{
// We first iterate through all the private endpoints and add them to the service endpoints list.
IList<Uri> serviceEndpoints = new List<Uri>();

if (customPrivateEndpoints != null
&& customPrivateEndpoints.Count > 0)
if (accountInitializationCustomEndpoints != null
&& accountInitializationCustomEndpoints.Count > 0)
{
foreach (string customEndpoint in customPrivateEndpoints)
foreach (string customEndpoint in accountInitializationCustomEndpoints)
{
// Add all of the custom private endpoints to the service endpoints list.
serviceEndpoints.Add(
Expand Down Expand Up @@ -628,7 +628,7 @@ internal async Task<AccountProperties> GetDatabaseAccountAsync(bool forceRefresh
singleValueInitFunc: () => GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(
this.defaultEndpoint,
this.connectionPolicy.PreferredLocations,
this.connectionPolicy.CustomPrivateEndpoints,
this.connectionPolicy.AccountInitializationCustomEndpoints,
this.GetDatabaseAccountAsync,
this.cancellationTokenSource.Token),
cancellationToken: this.cancellationTokenSource.Token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async Task InitializeReaderAsync_WhenCustomEndpointsProvided_ShouldRetryW

if (customEndpointsProvided)
{
connectionPolicy.SetCustomEndpoints(
connectionPolicy.SetAccountInitializationCustomEndpoints(
new HashSet<string>()
{
"https://testfed2.documents-test.windows-int.net:443/",
Expand Down Expand Up @@ -192,7 +192,7 @@ public async Task InitializeReaderAsync_WhenRegionalEndpointsProvided_ShouldThro
ConnectionMode = ConnectionMode.Direct,
};

connectionPolicy.SetCustomEndpoints(
connectionPolicy.SetAccountInitializationCustomEndpoints(
new HashSet<string>()
{
"https://testfed2.documents-test.windows-int.net:443/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ await GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) => throw new Exception("The operation should be canceled and never make the network call."),
cancellationTokenSource.Token);

Expand Down Expand Up @@ -148,7 +148,7 @@ await GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) =>
{
count++;
Expand Down Expand Up @@ -179,7 +179,7 @@ await GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: async (uri) =>
{
count++;
Expand Down Expand Up @@ -211,7 +211,7 @@ await GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) =>
{
count++;
Expand Down Expand Up @@ -243,7 +243,7 @@ await GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) =>
{
count++;
Expand Down Expand Up @@ -312,7 +312,7 @@ public async Task GetDatabaseAccountFromAnyLocationsMockTestAsync()
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) => slowPrimaryRegionHelper.RequestHelper(uri),
cancellationToken: default);

Expand All @@ -335,7 +335,7 @@ public async Task GetDatabaseAccountFromAnyLocationsMockTestAsync()
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) => slowPrimaryRegionHelper.RequestHelper(uri),
cancellationToken: default);
stopwatch.Stop();
Expand All @@ -359,7 +359,7 @@ public async Task GetDatabaseAccountFromAnyLocationsMockTestAsync()
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) => slowPrimaryRegionHelper.RequestHelper(uri),
cancellationToken: default);

Expand All @@ -381,7 +381,7 @@ public async Task GetDatabaseAccountFromAnyLocationsMockTestAsync()
"southeastasia",
"northcentralus"
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) => slowPrimaryRegionHelper.RequestHelper(uri),
cancellationToken: default);

Expand All @@ -407,7 +407,7 @@ public async Task GetDatabaseAccountFromAnyLocationsMockTestAsync()
"westus6",
"westus7",
},
customPrivateEndpoints: null,
accountInitializationCustomEndpoints: null,
getDatabaseAccountFn: (uri) => slowPrimaryRegionHelper.RequestHelper(uri),
cancellationToken: default);

Expand Down