Добавить Timeout клиента
This commit is contained in:
parent
84731fbf3c
commit
86ea991934
@ -31,6 +31,8 @@ namespace DD.Persistence.Client
|
|||||||
httpClient = httpClientFactory.CreateClient();
|
httpClient = httpClientFactory.CreateClient();
|
||||||
|
|
||||||
httpClient.Authorize(configuration);
|
httpClient.Authorize(configuration);
|
||||||
|
|
||||||
|
httpClient.Timeout = TimeSpan.FromSeconds(6000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IAuthTokenFactory authTokenFactory, IServiceProvider provider, IConfiguration configuration)
|
public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IAuthTokenFactory authTokenFactory, IServiceProvider provider, IConfiguration configuration)
|
||||||
@ -41,7 +43,9 @@ namespace DD.Persistence.Client
|
|||||||
|
|
||||||
var token = authTokenFactory.GetToken();
|
var token = authTokenFactory.GetToken();
|
||||||
httpClient.Authorize(token);
|
httpClient.Authorize(token);
|
||||||
}
|
|
||||||
|
httpClient.Timeout = TimeSpan.FromSeconds(6000);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить клиент для работы с уставками
|
/// Получить клиент для работы с уставками
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.9.34714.143
|
VisualStudioVersion = 17.9.34714.143
|
||||||
@ -19,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.Client", "DD
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.App", "DD.Persistence.App\DD.Persistence.App.csproj", "{063238BF-E982-43FA-9DDB-7D7D279086D8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.App", "DD.Persistence.App\DD.Persistence.App.csproj", "{063238BF-E982-43FA-9DDB-7D7D279086D8}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence.Benchmark", "Persistence.Benchmark\Persistence.Benchmark.csproj", "{27455F8C-6986-46F1-AD3E-B9D0C7AC85D1}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -57,6 +58,10 @@ Global
|
|||||||
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{27455F8C-6986-46F1-AD3E-B9D0C7AC85D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{27455F8C-6986-46F1-AD3E-B9D0C7AC85D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{27455F8C-6986-46F1-AD3E-B9D0C7AC85D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{27455F8C-6986-46F1-AD3E-B9D0C7AC85D1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Persistence.Benchmark.Database.Entities;
|
using Persistence.Benchmark.Database.Entities;
|
||||||
using Persistence.Database;
|
using DD.Persistence.Database;
|
||||||
|
|
||||||
namespace Persistence.Benchmark.Database;
|
namespace Persistence.Benchmark.Database;
|
||||||
public class BenchmarkDbContext : PersistenceDbContext
|
public class BenchmarkDbContext : PersistenceDbContext
|
||||||
|
@ -14,10 +14,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Persistence.API\Persistence.API.csproj" />
|
<ProjectReference Include="..\DD.Persistence.API\DD.Persistence.API.csproj" />
|
||||||
<ProjectReference Include="..\Persistence.Client\Persistence.Client.csproj" />
|
<ProjectReference Include="..\DD.Persistence.App\DD.Persistence.App.csproj" />
|
||||||
<ProjectReference Include="..\Persistence.Database.Postgres\Persistence.Database.Postgres.csproj" />
|
<ProjectReference Include="..\DD.Persistence.Client\DD.Persistence.Client.csproj" />
|
||||||
<ProjectReference Include="..\Persistence.Database\Persistence.Database.csproj" />
|
<ProjectReference Include="..\DD.Persistence.Database.Postgres\DD.Persistence.Database.Postgres.csproj" />
|
||||||
|
<ProjectReference Include="..\DD.Persistence.Database\DD.Persistence.Database.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using BenchmarkDotNet.Running;
|
using BenchmarkDotNet.Running;
|
||||||
using Persistence.Benchmark;
|
using Persistence.Benchmark;
|
||||||
using Persistence.Benchmark.Tests;
|
using Persistence.Benchmark.Tests;
|
||||||
using Persistence.API;
|
using DD.Persistence.API;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Persistence.Database;
|
using DD.Persistence.Database;
|
||||||
using Persistence.Database.Model;
|
using DD.Persistence.Database.Model;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Persistence.Benchmark;
|
namespace Persistence.Benchmark;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using BenchmarkDotNet.Engines;
|
using BenchmarkDotNet.Engines;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Persistence.Client;
|
using DD.Persistence.Client;
|
||||||
using Persistence.Client.Clients;
|
using DD.Persistence.Client.Clients;
|
||||||
using Persistence.Client.Clients.Interfaces;
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
using Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
|
|
||||||
namespace Persistence.Benchmark.Tests;
|
namespace Persistence.Benchmark.Tests;
|
||||||
|
|
||||||
@ -32,7 +32,8 @@ public class WitsDataTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//var data = GenerateData(1_000_000);
|
//var data = GenerateData(1_000_000);
|
||||||
var response = await client.AddRange(data, CancellationToken.None);
|
var source = new CancellationTokenSource(TimeSpan.FromSeconds(6000));
|
||||||
|
var response = await client.AddRange(data, source.Token);
|
||||||
Console.WriteLine(response.ToString());
|
Console.WriteLine(response.ToString());
|
||||||
//var discriminatorId = data.FirstOrDefault()!.DiscriminatorId;
|
//var discriminatorId = data.FirstOrDefault()!.DiscriminatorId;
|
||||||
//var date = DateTimeOffset.UtcNow.AddDays(-1);
|
//var date = DateTimeOffset.UtcNow.AddDays(-1);
|
||||||
@ -49,7 +50,7 @@ public class WitsDataTest
|
|||||||
[GlobalSetup]
|
[GlobalSetup]
|
||||||
public void GenerateData()
|
public void GenerateData()
|
||||||
{
|
{
|
||||||
int countToCreate = 5_000_000;
|
int countToCreate = 80_000_000;
|
||||||
|
|
||||||
var dtos = new List<WitsDataDto>();
|
var dtos = new List<WitsDataDto>();
|
||||||
|
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using DD.Persistence.Client;
|
||||||
|
using DD.Persistence.Database.Model;
|
||||||
|
using DD.Persistence.Database.Postgres;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Persistence.API;
|
|
||||||
using Persistence.Benchmark.Database;
|
using Persistence.Benchmark.Database;
|
||||||
using Persistence.Client;
|
|
||||||
using Persistence.Database.Model;
|
|
||||||
using Persistence.Database.Postgres;
|
|
||||||
|
|
||||||
namespace Persistence.Benchmark;
|
namespace Persistence.Benchmark;
|
||||||
public class WebAppFactoryFixture : WebApplicationFactory<Startup>
|
public class WebAppFactoryFixture : WebApplicationFactory<DD.Persistence.App.Program>
|
||||||
{
|
{
|
||||||
private string connectionString = string.Empty;
|
private string connectionString = string.Empty;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user