Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 5 additions & 1 deletion .github/workflows/slo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- AdoNet
- Dapper
- EF
- Linq2db.Slo
include:
- workload: AdoNet
read_rps: 1000
Expand All @@ -30,7 +31,10 @@ jobs:
- workload: EF
read_rps: 1000
write_rps: 100

- workload: Linq2db.Slo
read_rps: 1000
write_rps: 100

concurrency:
group: slo-${{ github.ref }}-${{ matrix.workload }}
cancel-in-progress: true
Expand Down
19 changes: 19 additions & 0 deletions slo/src/Linq2db.Slo/Linq2db.Slo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Linq2db</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Community.Ydb.Linq2db" Version="0.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Internal\Internal.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="linq2db" Version="6.0.0-rc.3" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions slo/src/Linq2db.Slo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using Linq2db;
using Internal;

await Cli.Run(new SloTableContext(), args);
107 changes: 107 additions & 0 deletions slo/src/Linq2db.Slo/SloLinq2DbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System;

Check warning on line 1 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[RedundantUsingDirective] Using directive is not required by the code and can be safely removed" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(1,1)
using System.Threading.Tasks;

Check warning on line 2 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[RedundantUsingDirective] Using directive is not required by the code and can be safely removed" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(2,1)
using LinqToDB;
using LinqToDB.Data;
using LinqToDB.Mapping;
using Internal;
using Linq2db.Ydb.Internal;
using LinqToDB.Async;
using LinqToDB.Internal.DataProvider.Ydb.Internal;

Check warning on line 9 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[RedundantUsingDirective] Using directive is not required by the code and can be safely removed" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(9,1)

namespace Linq2db;

public sealed class SloTableContext : SloTableContext<SloTableContext.Linq2dbClient>
{
protected override string Job => "Linq2DB";

static SloTableContext()
{
// Включаем ретраи SDK глобально (как и раньше)
YdbSdkRetryPolicyRegistration.UseGloballyWithIdempotence(
maxAttempts: 10,
onRetry: (attempt, ex, delay) => { /* лог/метрики при желании */ }

Check warning on line 22 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[UnusedParameter.Local] Parameter 'attempt' is never used" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(22,23)
);
}

public sealed class Linq2dbClient
{
private readonly string _connectionString;
public Linq2dbClient(string connectionString) => _connectionString = connectionString;
public DataConnection Open() => new DataConnection("YDB", _connectionString);

Check warning on line 30 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[CSharpWarnings::CS0618] CS0618: Constructor 'LinqToDB.Data.DataConnection.DataConnection(string, string)' is obsolete: 'This API scheduled for removal in v7. Instead use: new DataConnection(new DataOptions().UseConnectionString(dataProvider, connectionString))'" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(30,45)

Check warning on line 30 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

GitHub Actions / SLO test (Linq2db.Slo)

'DataConnection.DataConnection(string, string)' is obsolete: 'This API scheduled for removal in v7. Instead use: new DataConnection(new DataOptions().UseConnectionString(dataProvider, connectionString))'
}

protected override Linq2dbClient CreateClient(Config config) => new(config.ConnectionString);

protected override async Task Create(Linq2dbClient client, int operationTimeout)
{
await using var db = client.Open();
db.CommandTimeout = operationTimeout;

try
{
await db.ExecuteAsync($@"
CREATE TABLE `{SloTable.Name}` (
Guid Uuid,
Id Int32,
PayloadStr Text,
PayloadDouble Double,
PayloadTimestamp Timestamp,
PRIMARY KEY (Guid, Id)
)");
}
catch
{
// Таблица уже есть — ок
}

if (!string.IsNullOrWhiteSpace(SloTable.Options))
await db.ExecuteAsync(SloTable.Options);
}

// ВАЖНО: вернуть >0 при успехе, иначе write-графики будут пустые.
protected override async Task<int> Save(Linq2dbClient client, SloTable sloTable, int writeTimeout)
{
await using var db = client.Open();
db.CommandTimeout = writeTimeout;

var sql = $@"
UPSERT INTO `{SloTable.Name}` (Guid, Id, PayloadStr, PayloadDouble, PayloadTimestamp)
VALUES (@Guid, @Id, @PayloadStr, @PayloadDouble, @PayloadTimestamp);";

var affected = await db.ExecuteAsync(
sql,
new DataParameter("Guid", sloTable.Guid, DataType.Guid),
new DataParameter("Id", sloTable.Id, DataType.Int32),
new DataParameter("PayloadStr", sloTable.PayloadStr, DataType.NVarChar),
new DataParameter("PayloadDouble", sloTable.PayloadDouble, DataType.Double),
new DataParameter("PayloadTimestamp",sloTable.PayloadTimestamp,DataType.DateTime2)
);

return affected > 0 ? affected : 1;
}

protected override async Task<object?> Select(Linq2dbClient client, (Guid Guid, int Id) select, int readTimeout)
{
await using var db = client.Open();
db.CommandTimeout = readTimeout;

var t = db.GetTable<SloRow>();
return await t.FirstOrDefaultAsync(r => r.Guid == select.Guid && r.Id == select.Id);
}

protected override async Task<int> SelectCount(Linq2dbClient client)
{
await using var db = client.Open();
return await db.GetTable<SloRow>().CountAsync();
}

[Table(SloTable.Name)]
private sealed class SloRow
{
[Column] public Guid Guid { get; set; }

Check warning on line 101 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[UnusedAutoPropertyAccessor.Local] Auto-property accessor 'Guid.set' is never used" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(101,42)
[Column] public int Id { get; set; }

Check warning on line 102 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[UnusedAutoPropertyAccessor.Local] Auto-property accessor 'Id.set' is never used" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(102,39)
[Column] public string? PayloadStr { get; set; }

Check warning on line 103 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[UnusedMember.Local] Property 'PayloadStr' is never used" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(103,34)
[Column] public double PayloadDouble { get; set; }

Check warning on line 104 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[UnusedMember.Local] Property 'PayloadDouble' is never used" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(104,34)
[Column] public DateTime PayloadTimestamp { get; set; }

Check warning on line 105 in slo/src/Linq2db.Slo/SloLinq2DbContext.cs

View workflow job for this annotation

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

"[UnusedMember.Local] Property 'PayloadTimestamp' is never used" on /home/runner/work/ydb-dotnet-sdk/ydb-dotnet-sdk/slo/src/Linq2db.Slo/SloLinq2DbContext.cs(105,34)
}
}
6 changes: 6 additions & 0 deletions slo/src/src.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EF", "EF\EF.csproj", "{291A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdoNet.Dapper", "Dapper\AdoNet.Dapper.csproj", "{A6B9B4F1-4C7C-42C1-A212-B71A9B0D67F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Linq2db.Slo", "Linq2db.Slo\Linq2db.Slo.csproj", "{59758BC9-E53B-46C8-84AC-62670DD559D4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -39,6 +41,10 @@ Global
{A6B9B4F1-4C7C-42C1-A212-B71A9B0D67F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6B9B4F1-4C7C-42C1-A212-B71A9B0D67F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6B9B4F1-4C7C-42C1-A212-B71A9B0D67F7}.Release|Any CPU.Build.0 = Release|Any CPU
{59758BC9-E53B-46C8-84AC-62670DD559D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59758BC9-E53B-46C8-84AC-62670DD559D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59758BC9-E53B-46C8-84AC-62670DD559D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59758BC9-E53B-46C8-84AC-62670DD559D4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading