Skip to content

Commit 2791bef

Browse files
fix: delete default timeout grpc.deadline
1 parent 30c0e1f commit 2791bef

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

src/Ydb.Sdk/src/Ado/YdbCommand.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ public override string CommandText
7575
}
7676
}
7777

78+
/// <summary>
79+
/// The time to wait (in seconds) while trying to execute a command before terminating the attempt and generating an error.
80+
/// Set to zero for infinity.
81+
/// </summary>
82+
/// <value>
83+
/// The time (in seconds) to wait for the command to execute. The default value is 30 seconds.
84+
/// </value>
7885
public override int CommandTimeout
7986
{
8087
get => _timeout;
@@ -89,7 +96,7 @@ public override int CommandTimeout
8996
}
9097
}
9198

92-
private int _timeout;
99+
private int _timeout = 30;
93100

94101
public override CommandType CommandType { get; set; } = CommandType.Text;
95102
public override UpdateRowSource UpdatedRowSource { get; set; }

src/Ydb.Sdk/src/Driver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private async Task<Status> DiscoverEndpoints()
123123
TransportTimeout = Config.EndpointDiscoveryTimeout
124124
};
125125

126-
var options = GetCallOptions(requestSettings, false);
126+
var options = GetCallOptions(requestSettings);
127127
options.Headers.Add(Metadata.RpcSdkInfoHeader, _sdkInfo);
128128

129129
var response = await client.ListEndpointsAsync(

src/Ydb.Sdk/src/DriverConfig.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ public class DriverConfig
99
public string Database { get; }
1010
public ICredentialsProvider Credentials { get; }
1111
public X509Certificate? CustomServerCertificate { get; }
12-
public TimeSpan DefaultTransportTimeout { get; }
13-
public TimeSpan DefaultStreamingTransportTimeout { get; }
1412

1513
internal TimeSpan EndpointDiscoveryInterval = TimeSpan.FromMinutes(1);
1614
internal TimeSpan EndpointDiscoveryTimeout = TimeSpan.FromSeconds(10);
@@ -19,15 +17,11 @@ public DriverConfig(
1917
string endpoint,
2018
string database,
2119
ICredentialsProvider? credentials = null,
22-
TimeSpan? defaultTransportTimeout = null,
23-
TimeSpan? defaultStreamingTransportTimeout = null,
2420
X509Certificate? customServerCertificate = null)
2521
{
2622
Endpoint = FormatEndpoint(endpoint);
2723
Database = database;
2824
Credentials = credentials ?? new AnonymousProvider();
29-
DefaultTransportTimeout = defaultTransportTimeout ?? TimeSpan.FromMinutes(1);
30-
DefaultStreamingTransportTimeout = defaultStreamingTransportTimeout ?? TimeSpan.FromMinutes(10);
3125
CustomServerCertificate = customServerCertificate;
3226
}
3327

src/Ydb.Sdk/src/GrpcRequestSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class GrpcRequestSettings
99
internal static readonly GrpcRequestSettings DefaultInstance = new();
1010

1111
public string TraceId { get; set; } = string.Empty;
12-
public TimeSpan? TransportTimeout { get; set; }
12+
public TimeSpan TransportTimeout { get; set; } = TimeSpan.Zero;
1313
public ImmutableArray<string> CustomClientHeaders { get; } = new();
1414

1515
internal long NodeId { get; set; }

src/Ydb.Sdk/src/IDriver.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task<TResponse> UnaryCall<TRequest, TResponse>(
6969
using var call = callInvoker.AsyncUnaryCall(
7070
method: method,
7171
host: null,
72-
options: GetCallOptions(settings, false),
72+
options: GetCallOptions(settings),
7373
request: request
7474
);
7575

@@ -98,7 +98,7 @@ public ServerStream<TResponse> ServerStreamCall<TRequest, TResponse>(
9898
var call = callInvoker.AsyncServerStreamingCall(
9999
method: method,
100100
host: null,
101-
options: GetCallOptions(settings, true),
101+
options: GetCallOptions(settings),
102102
request: request);
103103

104104
return new ServerStream<TResponse>(call, e => { OnRpcError(endpoint, e); });
@@ -116,7 +116,7 @@ public IBidirectionalStream<TRequest, TResponse> BidirectionalStreamCall<TReques
116116
var call = callInvoker.AsyncDuplexStreamingCall(
117117
method: method,
118118
host: null,
119-
options: GetCallOptions(settings, true));
119+
options: GetCallOptions(settings));
120120

121121
return new BidirectionalStream<TRequest, TResponse>(call, e => { OnRpcError(endpoint, e); });
122122
}
@@ -125,7 +125,7 @@ public IBidirectionalStream<TRequest, TResponse> BidirectionalStreamCall<TReques
125125

126126
protected abstract void OnRpcError(string endpoint, RpcException e);
127127

128-
protected CallOptions GetCallOptions(GrpcRequestSettings settings, bool streaming)
128+
protected CallOptions GetCallOptions(GrpcRequestSettings settings)
129129
{
130130
var meta = new Grpc.Core.Metadata
131131
{
@@ -143,22 +143,13 @@ protected CallOptions GetCallOptions(GrpcRequestSettings settings, bool streamin
143143
meta.Add(Metadata.RpcTraceIdHeader, settings.TraceId);
144144
}
145145

146-
var transportTimeout = streaming
147-
? Config.DefaultStreamingTransportTimeout
148-
: Config.DefaultTransportTimeout;
149-
150-
if (settings.TransportTimeout != null)
151-
{
152-
transportTimeout = settings.TransportTimeout.Value;
153-
}
154-
155146
var options = new CallOptions(
156147
headers: meta
157148
);
158149

159-
if (transportTimeout != TimeSpan.Zero)
150+
if (settings.TransportTimeout != TimeSpan.Zero)
160151
{
161-
options = options.WithDeadline(DateTime.UtcNow + transportTimeout);
152+
options = options.WithDeadline(DateTime.UtcNow + settings.TransportTimeout);
162153
}
163154

164155
return options;

0 commit comments

Comments
 (0)