Add test for executor

This commit is contained in:
2025-11-11 02:15:57 +07:00
parent d02a07f86b
commit e8e2ec5a43
18 changed files with 81418 additions and 170 deletions

View File

@@ -5,6 +5,7 @@ using Managing.Infrastructure.Databases.InfluxDb.Models;
using Managing.Infrastructure.Databases.PostgreSql;
using Managing.Infrastructure.Databases.PostgreSql.Configurations;
using Microsoft.EntityFrameworkCore;
using Npgsql;
// Explicitly set the environment before creating the host builder
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -76,13 +77,32 @@ var host = hostBuilder
services.Configure<PostgreSqlSettings>(configuration.GetSection(Constants.Databases.PostgreSql));
services.Configure<InfluxDbSettings>(configuration.GetSection(Constants.Databases.InfluxDb));
// Build connection string with timeout and pooling settings
var connectionStringBuilder = new NpgsqlConnectionStringBuilder(postgreSqlConnectionString)
{
// Configure connection timeout (default is 15 seconds, increase for network latency)
Timeout = 30, // 30 seconds for connection establishment
CommandTimeout = 60, // 60 seconds for command execution
// Configure connection pooling for better performance and reliability
MaxPoolSize = 100, // Maximum pool size
MinPoolSize = 5, // Minimum pool size
// Configure KeepAlive to maintain connections and detect network issues
KeepAlive = 300 // 5 minutes keepalive interval
};
var enhancedConnectionString = connectionStringBuilder.ConnectionString;
// Add DbContext
services.AddDbContext<ManagingDbContext>((serviceProvider, options) =>
{
options.UseNpgsql(postgreSqlConnectionString, npgsqlOptions =>
options.UseNpgsql(enhancedConnectionString, npgsqlOptions =>
{
npgsqlOptions.CommandTimeout(60);
npgsqlOptions.EnableRetryOnFailure(maxRetryCount: 5, maxRetryDelay: TimeSpan.FromSeconds(10), errorCodesToAdd: null);
// Enable retry on failure for transient errors
npgsqlOptions.EnableRetryOnFailure(
maxRetryCount: 5,
maxRetryDelay: TimeSpan.FromSeconds(10),
errorCodesToAdd: null);
});
if (hostContext.HostingEnvironment.IsDevelopment())