Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Cosmos SDK V4 #21302

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ updates:
- dependency-name: Castle.Core
- dependency-name: Humanizer.Core
- dependency-name: IdentityServer4.EntityFramework
- dependency-name: Microsoft.Azure.Cosmos
- dependency-name: Azure.Cosmos
- dependency-name: Microsoft.CSharp
- dependency-name: Microsoft.Data.SqlClient
- dependency-name: Microsoft.DotNet.PlatformAbstractions
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/EFCore.Cosmos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.9.1" />
<PackageReference Include="Azure.Cosmos" Version="4.0.0-preview3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Azure.Cosmos;
using JetBrains.Annotations;
using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System;
using System.ComponentModel;
using System.Net;
using Azure.Cosmos;
using JetBrains.Annotations;
using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
Expand Down Expand Up @@ -59,14 +59,6 @@ public virtual CosmosDbContextOptionsBuilder Region([NotNull] string region)
public virtual CosmosDbContextOptionsBuilder LimitToEndpoint(bool enable = true)
=> WithOption(e => e.WithLimitToEndpoint(Check.NotNull(enable, nameof(enable))));

/// <summary>
/// Allows optimistic batching of requests to service. Setting this option might impact the latency of the operations.
/// Hence this option is recommended for non-latency sensitive scenarios only.
/// </summary>
/// <param name="enable"> <see langword="true"/> to allow optimistic batching of requests to service. </param>
public virtual CosmosDbContextOptionsBuilder AllowBulkExecution(bool enable = true)
=> WithOption(e => e.WithAllowBulkExecution(Check.NotNull(enable, nameof(enable))));

/// <summary>
/// Configures the context to use the provided connection mode.
/// </summary>
Expand Down Expand Up @@ -103,20 +95,6 @@ public virtual CosmosDbContextOptionsBuilder OpenTcpConnectionTimeout(TimeSpan t
public virtual CosmosDbContextOptionsBuilder IdleTcpConnectionTimeout(TimeSpan timeout)
=> WithOption(e => e.WithIdleTcpConnectionTimeout(Check.NotNull(timeout, nameof(timeout))));

/// <summary>
/// Configures the client port reuse policy used by the transport stack.
/// </summary>
/// <param name="portReuseMode"> The client port reuse policy used by the transport stack. </param>
public virtual CosmosDbContextOptionsBuilder PortReuseMode(PortReuseMode portReuseMode)
=> WithOption(e => e.WithPortReuseMode(Check.NotNull(portReuseMode, nameof(portReuseMode))));

/// <summary>
/// Configures the context to enable address cache refresh on TCP connection reset notification.
/// </summary>
/// <param name="enabled"> <see langword="true"/> to enable address cache refresh on TCP connection reset notification. </param>
public virtual CosmosDbContextOptionsBuilder EnableTcpConnectionEndpointRediscovery(bool enabled = true)
=> WithOption(e => e.WithTcpConnectionEndpointRediscovery(Check.NotNull(enabled, nameof(enabled))));

/// <summary>
/// Configures the maximum number of concurrent connections allowed for the target service endpoint
/// in the Azure Cosmos DB service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System.Globalization;
using System.Net;
using System.Text;
using Azure.Cosmos;
using JetBrains.Annotations;
using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
Expand All @@ -31,14 +31,11 @@ public class CosmosOptionsExtension : IDbContextOptionsExtension
private string _region;
private ConnectionMode? _connectionMode;
private bool? _limitToEndpoint;
private bool? _allowBulkExecution;
private Func<ExecutionStrategyDependencies, IExecutionStrategy> _executionStrategyFactory;
private IWebProxy _webProxy;
private TimeSpan? _requestTimeout;
private TimeSpan? _openTcpConnectionTimeout;
private TimeSpan? _idleTcpConnectionTimeout;
private PortReuseMode? _portReuseMode;
private bool? _enableTcpConnectionEndpointRediscovery;
private int? _gatewayModeMaxConnectionLimit;
private int? _maxTcpConnectionsPerEndpoint;
private int? _maxRequestsPerTcpConnection;
Expand Down Expand Up @@ -69,14 +66,11 @@ protected CosmosOptionsExtension([NotNull] CosmosOptionsExtension copyFrom)
_region = copyFrom._region;
_connectionMode = copyFrom._connectionMode;
_limitToEndpoint = copyFrom._limitToEndpoint;
_allowBulkExecution = copyFrom._allowBulkExecution;
_executionStrategyFactory = copyFrom._executionStrategyFactory;
_webProxy = copyFrom._webProxy;
_requestTimeout = copyFrom._requestTimeout;
_openTcpConnectionTimeout = copyFrom._openTcpConnectionTimeout;
_idleTcpConnectionTimeout = copyFrom._idleTcpConnectionTimeout;
_portReuseMode = copyFrom._portReuseMode;
_enableTcpConnectionEndpointRediscovery = copyFrom._enableTcpConnectionEndpointRediscovery;
_gatewayModeMaxConnectionLimit = copyFrom._gatewayModeMaxConnectionLimit;
_maxTcpConnectionsPerEndpoint = copyFrom._maxTcpConnectionsPerEndpoint;
_maxRequestsPerTcpConnection = copyFrom._maxRequestsPerTcpConnection;
Expand Down Expand Up @@ -244,29 +238,6 @@ public virtual CosmosOptionsExtension WithLimitToEndpoint(bool enable)
return clone;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool? AllowBulkExecution => _allowBulkExecution;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual CosmosOptionsExtension WithAllowBulkExecution(bool enable)
{
var clone = Clone();

clone._allowBulkExecution = enable;

return clone;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -387,52 +358,6 @@ public virtual CosmosOptionsExtension WithIdleTcpConnectionTimeout(TimeSpan time
return clone;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual PortReuseMode? PortReuseMode => _portReuseMode;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual CosmosOptionsExtension WithPortReuseMode(PortReuseMode portReuseMode)
{
var clone = Clone();

clone._portReuseMode = portReuseMode;

return clone;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool? TcpConnectionEndpointRediscoveryEnabled => _enableTcpConnectionEndpointRediscovery;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual CosmosOptionsExtension WithTcpConnectionEndpointRediscovery(bool enable)
{
var clone = Clone();

clone._enableTcpConnectionEndpointRediscovery = enable;

return clone;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -584,13 +509,10 @@ public override long GetServiceProviderHashCode()
hashCode = (hashCode * 397) ^ (Extension._region?.GetHashCode() ?? 0);
hashCode = (hashCode * 3) ^ (Extension._connectionMode?.GetHashCode() ?? 0);
hashCode = (hashCode * 3) ^ (Extension._limitToEndpoint?.GetHashCode() ?? 0);
hashCode = (hashCode * 3) ^ (Extension._allowBulkExecution?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Extension._webProxy?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Extension._requestTimeout?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Extension._openTcpConnectionTimeout?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Extension._idleTcpConnectionTimeout?.GetHashCode() ?? 0);
hashCode = (hashCode * 3) ^ (Extension._portReuseMode?.GetHashCode() ?? 0);
hashCode = (hashCode * 3) ^ (Extension._enableTcpConnectionEndpointRediscovery?.GetHashCode() ?? 0);
hashCode = (hashCode * 131) ^ (Extension._gatewayModeMaxConnectionLimit?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Extension._maxTcpConnectionsPerEndpoint?.GetHashCode() ?? 0);
hashCode = (hashCode * 131) ^ (Extension._maxRequestsPerTcpConnection?.GetHashCode() ?? 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Net;
using Azure.Cosmos;
using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand Down Expand Up @@ -65,14 +66,6 @@ public class CosmosSingletonOptions : ICosmosSingletonOptions
/// </summary>
public virtual bool? LimitToEndpoint { get; private set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool? AllowBulkExecution { get; private set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -113,22 +106,6 @@ public class CosmosSingletonOptions : ICosmosSingletonOptions
/// </summary>
public virtual TimeSpan? IdleTcpConnectionTimeout { get; private set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual PortReuseMode? PortReuseMode { get; private set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool? TcpConnectionEndpointRediscoveryEnabled { get; private set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -169,14 +146,11 @@ public virtual void Initialize(IDbContextOptions options)
ConnectionString = cosmosOptions.ConnectionString;
Region = cosmosOptions.Region;
LimitToEndpoint = cosmosOptions.LimitToEndpoint;
AllowBulkExecution = cosmosOptions.AllowBulkExecution;
ConnectionMode = cosmosOptions.ConnectionMode;
WebProxy = cosmosOptions.WebProxy;
RequestTimeout = cosmosOptions.RequestTimeout;
OpenTcpConnectionTimeout = cosmosOptions.OpenTcpConnectionTimeout;
IdleTcpConnectionTimeout = cosmosOptions.IdleTcpConnectionTimeout;
PortReuseMode = cosmosOptions.PortReuseMode;
TcpConnectionEndpointRediscoveryEnabled = cosmosOptions.TcpConnectionEndpointRediscoveryEnabled;
GatewayModeMaxConnectionLimit = cosmosOptions.GatewayModeMaxConnectionLimit;
MaxTcpConnectionsPerEndpoint = cosmosOptions.MaxTcpConnectionsPerEndpoint;
MaxRequestsPerTcpConnection = cosmosOptions.MaxRequestsPerTcpConnection;
Expand All @@ -199,14 +173,11 @@ public virtual void Validate(IDbContextOptions options)
|| ConnectionString != cosmosOptions.ConnectionString
|| Region != cosmosOptions.Region
|| LimitToEndpoint != cosmosOptions.LimitToEndpoint
|| AllowBulkExecution != cosmosOptions.AllowBulkExecution
|| ConnectionMode != cosmosOptions.ConnectionMode
|| WebProxy != cosmosOptions.WebProxy
|| RequestTimeout != cosmosOptions.RequestTimeout
|| OpenTcpConnectionTimeout != cosmosOptions.OpenTcpConnectionTimeout
|| IdleTcpConnectionTimeout != cosmosOptions.IdleTcpConnectionTimeout
|| PortReuseMode != cosmosOptions.PortReuseMode
|| TcpConnectionEndpointRediscoveryEnabled != cosmosOptions.TcpConnectionEndpointRediscoveryEnabled
|| GatewayModeMaxConnectionLimit != cosmosOptions.GatewayModeMaxConnectionLimit
|| MaxTcpConnectionsPerEndpoint != cosmosOptions.MaxTcpConnectionsPerEndpoint
|| MaxRequestsPerTcpConnection != cosmosOptions.MaxRequestsPerTcpConnection))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Net;
using Microsoft.Azure.Cosmos;
using Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -65,14 +65,6 @@ public interface ICosmosSingletonOptions : ISingletonOptions
/// </summary>
bool? LimitToEndpoint { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
bool? AllowBulkExecution { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -113,22 +105,6 @@ public interface ICosmosSingletonOptions : ISingletonOptions
/// </summary>
TimeSpan? IdleTcpConnectionTimeout { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
PortReuseMode? PortReuseMode { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
bool? TcpConnectionEndpointRediscoveryEnabled { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
Loading