Skip to content

Commit b79bdbb

Browse files
authored
Merge branch 'ydb-platform:main' into linq2db-examples-dev
2 parents 1e3f019 + 798ff29 commit b79bdbb

File tree

101 files changed

+2796
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2796
-521
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Restore
3232
run: dotnet restore ${{ matrix.source-dir }}${{ matrix.solutionFile }}
3333
- name: Install ReSharper
34-
run: dotnet tool install -g JetBrains.ReSharper.GlobalTools
34+
run: dotnet tool install -g JetBrains.ReSharper.GlobalTools --version 2025.2.1
3535
- name: format all files with auto-formatter
3636
run: bash ./.github/scripts/format-all-dotnet-code.sh ${{ matrix.source-dir }} ${{ matrix.solutionFile }}
3737
- name: Check repository diff
@@ -63,6 +63,7 @@ jobs:
6363
**.cshtml
6464
minimumReportSeverity: WARNING
6565
dotnetVersion: ${{ steps.setup-dotnet.outputs.dotnet-version }}
66+
version: 2025.2.1
6667
ignoreIssueType: |
6768
UnusedField.Compiler,
6869
UnusedVariable.Compiler,

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
ydb-sdk-tests:
1414
strategy:
1515
matrix:
16-
ydb-version: [ 'latest', '25.1' ]
16+
ydb-version: [ 'latest', 'trunk' ]
1717
dotnet-version: [ 8.0.x, 9.0.x ]
1818
runs-on: ubuntu-22.04
1919
services:
@@ -57,7 +57,7 @@ jobs:
5757
strategy:
5858
fail-fast: false
5959
matrix:
60-
ydb-version: [ 'latest', '25.1' ]
60+
ydb-version: [ 'latest', 'trunk' ]
6161
dotnet-version: [ 8.0.x, 9.0.x ]
6262
services:
6363
ydb:
@@ -139,4 +139,4 @@ jobs:
139139
dotnet add package Microsoft.EntityFrameworkCore.Design
140140
dotnet ef migrations add InitialCreate
141141
dotnet ef database update
142-
dotnet run
142+
dotnet run

examples/EntityFrameworkCore.Ydb.Yandex.Cloud/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ await Parser.Default.ParseArguments<CmdOptions>(args).WithParsedAsync(async cmd
1212

1313
var options = new DbContextOptionsBuilder<AppDbContext>()
1414
.UseYdb(cmd.ConnectionString, builder => builder
15-
.WithCredentialsProvider(saProvider)
16-
.WithServerCertificates(YcCerts.GetYcServerCertificates())
15+
.UseCredentialsProvider(saProvider)
16+
.UseServerCertificates(YcCerts.GetYcServerCertificates())
1717
)
1818
.Options;
1919

examples/Ydb.Sdk.AdoNet.Yandex.Cloud.Serverless.Container/Program.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics;
2+
using Dapper;
23
using Microsoft.Extensions.Configuration;
34
using Microsoft.Extensions.Logging;
45
using NLog.Extensions.Logging;
@@ -18,18 +19,17 @@
1819
var stopwatch = Stopwatch.StartNew();
1920
stopwatch.Start();
2021

21-
await using var dataSource = new YdbDataSource(
22-
new YdbConnectionStringBuilder(connectionString)
23-
{
24-
CredentialsProvider = new MetadataProvider(loggerFactory: loggerFactory),
25-
LoggerFactory = loggerFactory,
26-
DisableDiscovery = true
27-
}
28-
);
22+
await using var ydbDataSource = new YdbDataSource(new YdbConnectionStringBuilder(connectionString)
23+
{
24+
CredentialsProvider = new MetadataProvider(loggerFactory: loggerFactory),
25+
LoggerFactory = loggerFactory,
26+
DisableDiscovery = true,
27+
EnableImplicitSession = true
28+
});
2929

30-
await using var ydbCommand = dataSource.CreateCommand();
31-
ydbCommand.CommandText = "SELECT 'Hello Serverless YDB from Yandex Cloud Serverless Container!'u";
32-
var scalar = await ydbCommand.ExecuteScalarAsync();
30+
await using var ydbConnection = await ydbDataSource.OpenRetryableConnectionAsync();
31+
var scalar = await ydbConnection.ExecuteScalarAsync<string>(
32+
"SELECT 'Hello Serverless YDB from Yandex Cloud Serverless Container!'u");
3333
stopwatch.Stop();
3434

3535
logger.LogInformation("Success request! [Ms: {Ms}], {Select}", stopwatch.ElapsedMilliseconds, scalar);

examples/Ydb.Sdk.AdoNet.Yandex.Cloud.Serverless.Container/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,32 @@ to [Yandex Cloud Serverless Containers](https://yandex.cloud/en/docs/serverless-
66
## Getting started
77

88
1. **Setup** [Yandex Container Registry](https://yandex.cloud/en/docs/container-registry/operations/registry/registry-create).
9-
2. **Build and Push Docker Image**
9+
2. **Configure YDB Connection String**. Update the `appsettings.json` file with your YDB connection details:
10+
```json
11+
{
12+
"ConnectionStrings": {
13+
"ServerlessYDB": "UseTls=true;Host=<your-ydb-host>;Port=2135;Database=<your-database-path>"
14+
}
15+
}
16+
```
17+
Replace `<your-ydb-host>` with your YDB endpoint host and `<your-database-path>` with your database path (e.g., `/ru-central1/b1g8ejbxxxxxxxx/etn8xxxxxxxx`).
18+
3. **Build and Push Docker Image**
1019
```bash
1120
docker build . -t cr.yandex/<container-registry-id>/ado-net-app:latest
1221
docker push cr.yandex/<container-registry-id>/ado-net-app:latest
1322
```
1423
Replace <container-registry-id> with your actual Container Registry ID.
15-
3. **Grant Required Permissions**. To enable your Serverless Container to access both YDB and your container image in
24+
4. **Grant Required Permissions**. To enable your Serverless Container to access both YDB and your container image in
1625
the Container Registry, grant the following roles to your Service Account:
1726

1827
- `ydb.editor` — access to YDB,
1928
- `container-registry.images.puller` — permission to pull images from Container Registry.
2029

21-
4. **Create a new revision**. After pushing your image, create a new version of the Serverless Container as described in
30+
5. **Create a new revision**. After pushing your image, create a new version of the Serverless Container as described in
2231
the [official guide](https://yandex.cloud/en/docs/serverless-containers/quickstart/container#create-revision).
2332
Specify your image and the necessary environment variables and secrets.
2433

25-
5. **Running the Yandex Serverless Container**.
34+
6. **Running the Yandex Serverless Container**.
2635
After the new revision has been rolled out, you can use your container (e.g., for a health check) by executing the
2736
following command:
2837
```bash

examples/Ydb.Sdk.AdoNet.Yandex.Cloud.Serverless.Container/Ydb.Sdk.AdoNet.Yandex.Cloud.Serverless.Container.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
1616
<PackageReference Include="NLog.Extensions.Logging" Version="5.5.0"/>
1717
<PackageReference Include="Ydb.Sdk.Yc.Auth" Version="0.2.0"/>
18-
<PackageReference Include="Ydb.Sdk" Version="0.18.0"/>
18+
<PackageReference Include="Ydb.Sdk" Version="0.24.0"/>
19+
<PackageReference Include="Dapper" Version="2.1.35"/>
1920

2021
<None Update="appsettings.json">
2122
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

examples/Ydb.Sdk.Topic.QuickStart/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Microsoft.Extensions.Logging;
22
using Ydb.Sdk;
3-
using Ydb.Sdk.Services.Topic;
4-
using Ydb.Sdk.Services.Topic.Reader;
5-
using Ydb.Sdk.Services.Topic.Writer;
3+
using Ydb.Sdk.Topic;
4+
using Ydb.Sdk.Topic.Reader;
5+
using Ydb.Sdk.Topic.Writer;
66

77
const int countMessages = 100;
88
const string topicName = "topic_name";

slo/src/EF/SloTableContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public class SloTableContext : SloTableContext<PooledDbContextFactory<TableDbCon
1212
protected override string Job => "EF";
1313

1414
protected override PooledDbContextFactory<TableDbContext> CreateClient(Config config) =>
15-
new(new DbContextOptionsBuilder<TableDbContext>().UseYdb(config.ConnectionString).Options);
15+
new(new DbContextOptionsBuilder<TableDbContext>().UseYdb(config.ConnectionString,
16+
builder => builder.EnableRetryIdempotence()).Options);
1617

1718
protected override async Task Create(
1819
PooledDbContextFactory<TableDbContext> client,

slo/src/Internal/SloTableContext.cs

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using NLog.Extensions.Logging;
66
using Prometheus;
77
using Ydb.Sdk;
8-
using Ydb.Sdk.Ado;
98

109
namespace Internal;
1110

@@ -151,11 +150,6 @@ async Task ShootingTask(RateLimiter rateLimitPolicy, string operationType, Func<
151150
"Total number of successful operations, categorized by type."
152151
);
153152

154-
var operationsFailureTotal = metricFactory.CreateCounter(
155-
"sdk_operations_failure_total",
156-
"Total number of failed operations, categorized by type."
157-
);
158-
159153
var operationLatencySeconds = metricFactory.CreateHistogram(
160154
"sdk_operation_latency_seconds",
161155
"Latency of operations performed by the SDK in seconds, categorized by type and status.",
@@ -186,12 +180,6 @@ async Task ShootingTask(RateLimiter rateLimitPolicy, string operationType, Func<
186180
"Current number of pending operations, categorized by type."
187181
);
188182

189-
var errorsTotal = metricFactory.CreateCounter(
190-
"sdk_errors_total",
191-
"Total number of errors encountered, categorized by error type.",
192-
["error_type"]
193-
);
194-
195183
var workJobs = new List<Task>();
196184

197185
for (var i = 0; i < 10; i++)
@@ -210,23 +198,12 @@ async Task ShootingTask(RateLimiter rateLimitPolicy, string operationType, Func<
210198

211199
pendingOperations.Inc();
212200
var sw = Stopwatch.StartNew();
213-
try
214-
{
215-
await action(client, runConfig);
216-
sw.Stop();
217-
operationsTotal.Inc();
218-
pendingOperations.Dec();
219-
operationsSuccessTotal.Inc();
220-
operationLatencySeconds.WithLabels("success").Observe(sw.Elapsed.TotalSeconds);
221-
}
222-
catch (YdbException e)
223-
{
224-
Logger.LogError(e, "Fail operation!");
225-
226-
errorsTotal.WithLabels(e.Code.StatusName()).Inc();
227-
operationsFailureTotal.Inc();
228-
operationLatencySeconds.WithLabels("err").Observe(sw.Elapsed.TotalSeconds);
229-
}
201+
await action(client, runConfig);
202+
sw.Stop();
203+
operationsTotal.Inc();
204+
pendingOperations.Dec();
205+
operationsSuccessTotal.Inc();
206+
operationLatencySeconds.WithLabels("success").Observe(sw.Elapsed.TotalSeconds);
230207
}
231208
}, cancellationTokenSource.Token));
232209
}

slo/src/TopicService/SloTopicContext.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
using Microsoft.Extensions.Logging;
55
using Ydb.Sdk;
66
using Ydb.Sdk.Ado;
7-
using Ydb.Sdk.Services.Topic;
8-
using Ydb.Sdk.Services.Topic.Reader;
9-
using Ydb.Sdk.Services.Topic.Writer;
7+
using Ydb.Sdk.Topic;
8+
using Ydb.Sdk.Topic.Reader;
9+
using Ydb.Sdk.Topic.Writer;
1010

1111
namespace TopicService;
1212

@@ -332,7 +332,7 @@ int partitionId
332332
}
333333

334334
private static void CheckMessage(ConcurrentDictionary<long, ConcurrentQueue<string>> localStore,
335-
Ydb.Sdk.Services.Topic.Reader.Message<string> message)
335+
Ydb.Sdk.Topic.Reader.Message<string> message)
336336
{
337337
if (localStore.TryGetValue(message.PartitionId, out var partition))
338338
{
@@ -363,7 +363,7 @@ private static string PrintLocalStore(ConcurrentDictionary<long, ConcurrentQueue
363363
string.Join("\n", localStore.Select(pair => pair.Key + ": " + string.Join(", ", pair.Value))) +
364364
"]";
365365

366-
private static void AssertMessage(Ydb.Sdk.Services.Topic.Reader.Message<string> message, string expectedMessageData)
366+
private static void AssertMessage(Ydb.Sdk.Topic.Reader.Message<string> message, string expectedMessageData)
367367
{
368368
if (expectedMessageData == message.Data)
369369
{

0 commit comments

Comments
 (0)