File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed
src/Ydb.Sdk/src/Transport Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 1+ using Grpc . Core ;
2+ using Grpc . Net . Client ;
3+ using Microsoft . Extensions . Logging ;
4+
5+ namespace Ydb . Sdk . Transport ;
6+
7+ internal class FixedGrpcChannelTransport : GrpcTransport
8+ {
9+ private readonly GrpcChannel _channel ;
10+
11+ public FixedGrpcChannelTransport (
12+ DriverConfig driverConfig ,
13+ ILogger logger
14+ ) : base (
15+ new DriverConfig (
16+ endpoint : driverConfig . Endpoint ,
17+ database : driverConfig . Database ,
18+ customServerCertificate : driverConfig . CustomServerCertificate
19+ ) , logger
20+ )
21+ {
22+ _channel = ChannelsCache . CreateChannel ( Config . Endpoint , Config ) ;
23+ }
24+
25+ protected override void Dispose ( bool disposing )
26+ {
27+ if ( disposing )
28+ {
29+ _channel . Dispose ( ) ;
30+ }
31+ }
32+
33+ protected override ( string , GrpcChannel ) GetChannel ( )
34+ {
35+ return ( Config . Endpoint , _channel ) ;
36+ }
37+
38+ protected override void OnRpcError ( string endpoint , RpcException e )
39+ {
40+ var status = e . Status ;
41+ if ( e . Status . StatusCode != Grpc . Core . StatusCode . OK )
42+ {
43+ Logger . LogWarning ( "gRPC error {StatusCode}[{Detail}] on fixed channel {Endpoint}" ,
44+ status . StatusCode , status . Detail , endpoint ) ;
45+ }
46+ }
47+ }
Original file line number Diff line number Diff line change 22using Grpc . Net . Client ;
33using Microsoft . Extensions . Logging ;
44
5- namespace Ydb . Sdk ;
5+ namespace Ydb . Sdk . Transport ;
66
77// TODO Experimental [for Driver with fix call options]
88public abstract class GrpcTransport : IDisposable , IAsyncDisposable
99{
10- protected readonly ILogger Logger ;
1110 protected readonly DriverConfig Config ;
11+ protected readonly ILogger Logger ;
1212
1313 internal GrpcTransport ( DriverConfig driverConfig , ILogger logger )
1414 {
You can’t perform that action at this time.
0 commit comments