11using System . Collections . Immutable ;
2- using System . Reflection ;
32using Grpc . Core ;
43using Grpc . Net . Client ;
54using Microsoft . Extensions . Logging ;
@@ -16,7 +15,6 @@ public sealed class Driver : BaseDriver
1615{
1716 private const int AttemptDiscovery = 10 ;
1817
19- private readonly string _sdkInfo ;
2018 private readonly GrpcChannelFactory _grpcChannelFactory ;
2119 private readonly EndpointPool _endpointPool ;
2220 private readonly ChannelPool < GrpcChannel > _channelPool ;
@@ -35,10 +33,6 @@ public Driver(DriverConfig config, ILoggerFactory? loggerFactory = null)
3533 _grpcChannelFactory
3634 ) ;
3735
38- var version = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
39- var versionStr = version is null ? "unknown" : version . ToString ( 3 ) ;
40- _sdkInfo = $ "ydb-dotnet-sdk/{ versionStr } ";
41-
4236 CredentialsProvider = Config . User != null
4337 ? new CachedCredentialsProvider (
4438 new StaticCredentialsAuthClient ( config , _grpcChannelFactory , LoggerFactory ) ,
@@ -134,12 +128,10 @@ private async Task<Status> DiscoverEndpoints()
134128 TransportTimeout = Config . EndpointDiscoveryTimeout
135129 } ;
136130
137- var options = await GetCallOptions ( requestSettings ) ;
138- options . Headers ? . Add ( Metadata . RpcSdkInfoHeader , _sdkInfo ) ;
139-
140131 var response = await client . ListEndpointsAsync (
141132 request : request ,
142- options : options ) ;
133+ options : await GetCallOptions ( requestSettings )
134+ ) ;
143135
144136 if ( ! response . Operation . Ready )
145137 {
@@ -168,7 +160,8 @@ private async Task<Status> DiscoverEndpoints()
168160
169161 Logger . LogDebug (
170162 "Successfully discovered endpoints: {EndpointsCount}, self location: {SelfLocation}, sdk info: {SdkInfo}" ,
171- resultProto . Endpoints . Count , resultProto . SelfLocation , _sdkInfo ) ;
163+ resultProto . Endpoints . Count , resultProto . SelfLocation , Config . SdkVersion
164+ ) ;
172165
173166 _endpointPool . Reset ( resultProto . Endpoints
174167 . Select ( endpointSettings => new EndpointSettings (
@@ -189,15 +182,16 @@ private async Task PeriodicDiscovery()
189182 try
190183 {
191184 await Task . Delay ( Config . EndpointDiscoveryInterval ) ;
185+
192186 _ = await DiscoverEndpoints ( ) ;
193187 }
194188 catch ( RpcException e )
195189 {
196- Logger . LogWarning ( $ "RPC error during endpoint discovery: { e . Status } ") ;
190+ Logger . LogWarning ( "RPC error during endpoint discovery: {Status}" , e . Status ) ;
197191 }
198192 catch ( Exception e )
199193 {
200- Logger . LogError ( $ "Unexpected exception during session pool periodic check: { e } ") ;
194+ Logger . LogError ( e , "Unexpected exception during session pool periodic check" ) ;
201195 }
202196 }
203197 }
0 commit comments