Share via


你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

CosmosClientBuilder.WithConnectionModeDirect 方法

定义

重载

WithConnectionModeDirect()

将连接模式设置为“直接”。 客户端在连接到 Azure Cosmos DB 服务时使用此服务。

WithConnectionModeDirect(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<Int32>, Nullable<Int32>, Nullable<PortReuseMode>, Nullable<Boolean>)

将连接模式设置为“直接”。 客户端在连接到 Azure Cosmos DB 服务时使用此服务。

WithConnectionModeDirect()

Source:
CosmosClientBuilder.cs

将连接模式设置为“直接”。 客户端在连接到 Azure Cosmos DB 服务时使用此服务。

public Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder WithConnectionModeDirect ();
member this.WithConnectionModeDirect : unit -> Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder
Public Function WithConnectionModeDirect () As CosmosClientBuilder

返回

当前的 CosmosClientBuilder

注解

有关详细信息,请参阅 连接策略:使用直接连接模式

另请参阅

适用于

WithConnectionModeDirect(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<Int32>, Nullable<Int32>, Nullable<PortReuseMode>, Nullable<Boolean>)

Source:
CosmosClientBuilder.cs

将连接模式设置为“直接”。 客户端在连接到 Azure Cosmos DB 服务时使用此服务。

public Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder WithConnectionModeDirect (TimeSpan? idleTcpConnectionTimeout = default, TimeSpan? openTcpConnectionTimeout = default, int? maxRequestsPerTcpConnection = default, int? maxTcpConnectionsPerEndpoint = default, Microsoft.Azure.Cosmos.PortReuseMode? portReuseMode = default, bool? enableTcpConnectionEndpointRediscovery = default);
member this.WithConnectionModeDirect : Nullable<TimeSpan> * Nullable<TimeSpan> * Nullable<int> * Nullable<int> * Nullable<Microsoft.Azure.Cosmos.PortReuseMode> * Nullable<bool> -> Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder
Public Function WithConnectionModeDirect (Optional idleTcpConnectionTimeout As Nullable(Of TimeSpan) = Nothing, Optional openTcpConnectionTimeout As Nullable(Of TimeSpan) = Nothing, Optional maxRequestsPerTcpConnection As Nullable(Of Integer) = Nothing, Optional maxTcpConnectionsPerEndpoint As Nullable(Of Integer) = Nothing, Optional portReuseMode As Nullable(Of PortReuseMode) = Nothing, Optional enableTcpConnectionEndpointRediscovery As Nullable(Of Boolean) = Nothing) As CosmosClientBuilder

参数

idleTcpConnectionTimeout
Nullable<TimeSpan>

控制空闲时间,在此时间后关闭未使用的连接。 默认情况下,空闲连接会无限期地保持为打开状态。 值必须大于或等于 10 分钟。 建议值介于 20 分钟到 24 小时之间。 主要适用于对大型数据库帐户的稀疏不频繁访问。

openTcpConnectionTimeout
Nullable<TimeSpan>

控制尝试建立连接所允许的时间。 默认超时为 5 秒。 建议的值大于或等于 5 秒。 时间过后,将取消尝试并返回错误。 超时时间较长将延迟重试和失败。

maxRequestsPerTcpConnection
Nullable<Int32>

控制通过单个 TCP 连接同时允许的请求数。 当更多请求同时处于未完成状态时,直接/TCP 客户端将打开其他连接。 默认设置允许每个连接同时发出 30 个请求。 不要将此值设置为低于每个连接 4 个请求或每个连接超过 50-100 个请求。
前者可能会导致创建大量连接。 后者可能导致线路头阻塞、高延迟和超时。 每个连接并行度非常高、请求或响应较大,或者延迟要求非常严格的应用程序可能会获得更好的性能,每个连接 8-16 个请求。

maxTcpConnectionsPerEndpoint
Nullable<Int32>

控制可向每个 Cosmos DB 后端打开的最大 TCP 连接数。 此设置与 MaxRequestsPerTcpConnection 配合使用,限制同时发送到单个 Cosmos DB 后端 (MaxRequestsPerTcpConnection x MaxTcpConnectionPerEndpoint) 的请求数。 默认值为 65,535。 值必须大于或等于 16。

portReuseMode
Nullable<PortReuseMode>

(Direct/TCP) 控制传输堆栈使用的客户端端口重用策略。 默认值为 PortReuseMode.ReuseUnicastPort。

enableTcpConnectionEndpointRediscovery
Nullable<Boolean>

(Direct/TCP) 控制 TCP 连接重置通知上的地址缓存刷新。 默认值为 false。

返回

当前的 CosmosClientBuilder

注解

有关详细信息,请参阅 连接策略:使用直接连接模式

另请参阅

适用于