Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Ydb.Sdk.Ado;
using Ydb.Sdk.Yc;

Expand All @@ -11,8 +12,9 @@
.GetConnectionString("ServerlessYDB") ??
throw new InvalidOperationException("ConnectionString.ServerlessYDB is empty.");

var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Information));
var loggerFactory = LoggerFactory.Create(builder => builder.AddNLog());
var logger = loggerFactory.CreateLogger<Program>();

var stopwatch = Stopwatch.StartNew();
stopwatch.Start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Ydb.Sdk.Yc.Auth" Version="0.2.0" />
<PackageReference Include="Ydb.Sdk" Version="0.18.0" />
<PackageReference Include="CommandLineParser" Version="2.8.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
<PackageReference Include="NLog.Extensions.Logging" Version="5.5.0"/>
<PackageReference Include="Ydb.Sdk.Yc.Auth" Version="0.2.0"/>
<PackageReference Include="Ydb.Sdk" Version="0.18.0"/>

<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"ServerlessYDB": "UseTls=true;Host=<host>;Port=2135;Database=<database>"
"ServerlessYDB": "UseTls=true;Host=ydb.serverless.yandexcloud.net;Port=2135;Database=/ru-central1/b1g8skpblkos03malf3s/etnl7uv72neobbgiahii"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<targets>
<target xsi:type="Console" name="ConsoleTarget">
<layout xsi:type="JsonLayout">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}" />
<attribute name="logger" layout="${logger}" />
<attribute name="message" layout="${message}" />
<attribute name='exception' layout='${exception:format=toString,StackTrace}' />
</layout>
</target>
</targets>

<rules>
<logger name="*" minlevel="Info" writeTo="ConsoleTarget" />
</rules>
</nlog>
11 changes: 8 additions & 3 deletions src/Ydb.Sdk/src/Pool/ChannelPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Security.Cryptography.X509Certificates;
using Grpc.Core;
using Grpc.Net.Client;
using Grpc.Net.Client.Configuration;
using Microsoft.Extensions.Logging;

namespace Ydb.Sdk.Pool;
Expand Down Expand Up @@ -97,7 +98,11 @@
LoggerFactory = _loggerFactory,
DisposeHttpClient = true,
MaxSendMessageSize = _config.MaxSendMessageSize,
MaxReceiveMessageSize = _config.MaxReceiveMessageSize
MaxReceiveMessageSize = _config.MaxReceiveMessageSize,
ServiceConfig = new ServiceConfig
{
LoadBalancingConfigs = { new RoundRobinConfig() }
}
};

var httpHandler = new SocketsHttpHandler
Expand All @@ -110,13 +115,13 @@
};

// https://github.com/grpc/grpc-dotnet/issues/2312#issuecomment-1790661801
httpHandler.Properties["__GrpcLoadBalancingDisabled"] = true;
// httpHandler.Properties["__GrpcLoadBalancingDisabled"] = true;

channelOptions.HttpHandler = httpHandler;

if (ServerCertificates.Count == 0)
{
return GrpcChannel.ForAddress(endpoint, channelOptions);
return GrpcChannel.ForAddress(new Uri(endpoint) { }, channelOptions);

Check warning on line 124 in src/Ydb.Sdk/src/Pool/ChannelPool.cs

View workflow job for this annotation

GitHub Actions / Inspection (./src/YdbSdk.sln)

"[RedundantEmptyObjectOrCollectionInitializer] Empty object or collection initializer list is redundant" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/src/Ydb.Sdk/src/Pool/ChannelPool.cs(124,61)
}

httpHandler.SslOptions.RemoteCertificateValidationCallback +=
Expand Down
Loading