Skip to content

Commit

Permalink
dev: preparing for release (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillKurdyukov committed Aug 7, 2024
1 parent e4e2218 commit c9e4aa6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Ydb.Sdk/src/Ado/YdbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override async Task OpenAsync(CancellationToken cancellationToken)
{
Driver.TransportException transportException => new YdbException(transportException.Status),
StatusUnsuccessfulException unsuccessfulException => new YdbException(unsuccessfulException.Status),
_ => throw new YdbException("Cannot get session", e)
_ => new YdbException("Cannot get session", e)
};
}

Expand Down
19 changes: 6 additions & 13 deletions src/Ydb.Sdk/src/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ internal async Task<TResponse> UnaryCall<TRequest, TResponse>(
catch (RpcException e)
{
PessimizeEndpoint(endpoint);

throw new TransportException(e);
}
}
Expand All @@ -167,15 +168,10 @@ internal StreamIterator<TResponse> StreamCall<TRequest, TResponse>(
options: GetCallOptions(settings, true),
request: request);

return new StreamIterator<TResponse>(call, e =>
{
settings.RpcErrorHandler(e);
PessimizeEndpoint(endpoint);
});
return new StreamIterator<TResponse>(call, () => { PessimizeEndpoint(endpoint); });
}
catch (RpcException e)
{
settings.RpcErrorHandler(e);
PessimizeEndpoint(endpoint);

throw new TransportException(e);
Expand Down Expand Up @@ -326,9 +322,9 @@ private CallOptions GetCallOptions(GrpcRequestSettings settings, bool streaming)
internal sealed class StreamIterator<TResponse> : IAsyncEnumerator<TResponse>, IAsyncEnumerable<TResponse>
{
private readonly AsyncServerStreamingCall<TResponse> _responseStream;
private readonly Action<RpcException> _rpcErrorAction;
private readonly Action _rpcErrorAction;

internal StreamIterator(AsyncServerStreamingCall<TResponse> responseStream, Action<RpcException> rpcErrorAction)
internal StreamIterator(AsyncServerStreamingCall<TResponse> responseStream, Action rpcErrorAction)
{
_responseStream = responseStream;
_rpcErrorAction = rpcErrorAction;
Expand All @@ -349,7 +345,8 @@ public async ValueTask<bool> MoveNextAsync()
}
catch (RpcException e)
{
_rpcErrorAction(e);
_rpcErrorAction();

throw new TransportException(e);
}
}
Expand All @@ -367,10 +364,6 @@ public class InitializationFailureException : Exception
internal InitializationFailureException(string message) : base(message)
{
}

internal InitializationFailureException(string message, Exception inner) : base(message, inner)
{
}
}

public class TransportException : IOException
Expand Down
8 changes: 2 additions & 6 deletions src/Ydb.Sdk/src/GrpcRequestSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Immutable;
using Google.Protobuf.WellKnownTypes;
using Grpc.Core;
using Ydb.Operations;

namespace Ydb.Sdk;
Expand All @@ -11,13 +10,10 @@ public class GrpcRequestSettings

public string TraceId { get; set; } = string.Empty;
public TimeSpan? TransportTimeout { get; set; }
public ImmutableArray<string> CustomClientHeaders { get; set; }
public ImmutableArray<string> CustomClientHeaders { get; } = new();

internal long NodeId { get; set; }

internal Action<Grpc.Core.Metadata?> TrailersHandler { get; set; } = _ => { };

internal Action<RpcException> RpcErrorHandler { get; set; } = _ => { };
internal Action<Grpc.Core.Metadata> TrailersHandler { get; set; } = _ => { };
}

public class OperationSettings : GrpcRequestSettings
Expand Down
13 changes: 3 additions & 10 deletions src/Ydb.Sdk/src/Services/Query/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ protected override async Task<Session> CreateSession()
return;
}
var statusSession = Status.FromProto(stream.Current.Status, stream.Current.Issues);
if (statusSession.IsNotSuccess)
{
completeTask.SetResult(statusSession);
}
completeTask.SetResult(Status.Success);
completeTask.SetResult(Status.FromProto(stream.Current.Status, stream.Current.Issues));
try
{
Expand All @@ -85,9 +78,9 @@ protected override async Task<Session> CreateSession()
{
}
}
catch (Driver.TransportException e)
catch (Exception e)
{
completeTask.SetResult(e.Status);
completeTask.SetException(e);
}
finally
{
Expand Down
7 changes: 1 addition & 6 deletions src/Ydb.Sdk/src/Services/Table/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ private void OnResponseStatus(Status status)
}
}

private void OnResponseTrailers(Grpc.Core.Metadata? trailers)
private void OnResponseTrailers(Grpc.Core.Metadata trailers)
{
if (trailers is null)
{
return;
}

foreach (var hint in trailers.GetAll(Metadata.RpcServerHintsHeader))
{
if (hint.Value == Metadata.GracefulShutdownHint)
Expand Down

0 comments on commit c9e4aa6

Please sign in to comment.