remove locks around metrics for testing, add back dbcontext pooling
This commit is contained in:
@@ -13,10 +13,10 @@ namespace MareSynchronosServer.Metrics
|
|||||||
|
|
||||||
public void Inc(double inc = 1d)
|
public void Inc(double inc = 1d)
|
||||||
{
|
{
|
||||||
lock (_c)
|
//lock (_c)
|
||||||
{
|
//{
|
||||||
_c.Inc(inc);
|
_c.Inc(inc);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,34 +13,34 @@ public class LockedProxyGauge
|
|||||||
|
|
||||||
public void Inc(double inc = 1d)
|
public void Inc(double inc = 1d)
|
||||||
{
|
{
|
||||||
lock (_g)
|
//lock (_g)
|
||||||
{
|
//{
|
||||||
_g.Inc(inc);
|
_g.Inc(inc);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncTo(double incTo)
|
public void IncTo(double incTo)
|
||||||
{
|
{
|
||||||
lock (_g)
|
//lock (_g)
|
||||||
{
|
//{
|
||||||
_g.IncTo(incTo);
|
_g.IncTo(incTo);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dec(double decBy = 1d)
|
public void Dec(double decBy = 1d)
|
||||||
{
|
{
|
||||||
lock (_g)
|
//lock (_g)
|
||||||
{
|
//{
|
||||||
_g.Dec(decBy);
|
_g.Dec(decBy);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Set(double setTo)
|
public void Set(double setTo)
|
||||||
{
|
{
|
||||||
lock (_g)
|
//lock (_g)
|
||||||
{
|
//{
|
||||||
_g.Set(setTo);
|
_g.Set(setTo);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Value => _g.Value;
|
public double Value => _g.Value;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace MareSynchronosServer
|
|||||||
using (var scope = host.Services.CreateScope())
|
using (var scope = host.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var services = scope.ServiceProvider;
|
var services = scope.ServiceProvider;
|
||||||
var context = services.GetRequiredService<MareDbContext>();
|
using var context = services.GetRequiredService<MareDbContext>();
|
||||||
context.Database.Migrate();
|
context.Database.Migrate();
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using MareSynchronos.API;
|
using MareSynchronos.API;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
@@ -13,7 +12,6 @@ using Microsoft.AspNetCore.Authentication;
|
|||||||
using Microsoft.AspNetCore.Http.Connections;
|
using Microsoft.AspNetCore.Http.Connections;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Prometheus;
|
using Prometheus;
|
||||||
using WebSocketOptions = Microsoft.AspNetCore.Builder.WebSocketOptions;
|
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using MareSynchronosServer.Discord;
|
using MareSynchronosServer.Discord;
|
||||||
@@ -48,13 +46,14 @@ namespace MareSynchronosServer
|
|||||||
services.AddSingleton<IUserIdProvider, IdBasedUserIdProvider>();
|
services.AddSingleton<IUserIdProvider, IdBasedUserIdProvider>();
|
||||||
services.AddTransient(_ => Configuration);
|
services.AddTransient(_ => Configuration);
|
||||||
|
|
||||||
services.AddDbContext<MareDbContext>(options =>
|
services.AddDbContextPool<MareDbContext>(options =>
|
||||||
{
|
{
|
||||||
|
options.EnableThreadSafetyChecks(false);
|
||||||
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"), builder =>
|
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"), builder =>
|
||||||
{
|
{
|
||||||
builder.MigrationsHistoryTable("_efmigrationshistory", "public");
|
builder.MigrationsHistoryTable("_efmigrationshistory", "public");
|
||||||
}).UseSnakeCaseNamingConvention();
|
}).UseSnakeCaseNamingConvention();
|
||||||
});
|
}, Configuration.GetValue("DbContextPoolSize", 1024));
|
||||||
|
|
||||||
services.AddHostedService<CleanupService>();
|
services.AddHostedService<CleanupService>();
|
||||||
services.AddHostedService(provider => provider.GetService<SystemInfoService>());
|
services.AddHostedService(provider => provider.GetService<SystemInfoService>());
|
||||||
@@ -64,7 +63,7 @@ namespace MareSynchronosServer
|
|||||||
{
|
{
|
||||||
options.DefaultScheme = SecretKeyAuthenticationHandler.AuthScheme;
|
options.DefaultScheme = SecretKeyAuthenticationHandler.AuthScheme;
|
||||||
})
|
})
|
||||||
.AddScheme<AuthenticationSchemeOptions, SecretKeyAuthenticationHandler>(SecretKeyAuthenticationHandler.AuthScheme, options => {});
|
.AddScheme<AuthenticationSchemeOptions, SecretKeyAuthenticationHandler>(SecretKeyAuthenticationHandler.AuthScheme, options => { });
|
||||||
services.AddAuthorization(options => options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build());
|
services.AddAuthorization(options => options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build());
|
||||||
|
|
||||||
services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
|
services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"DbContextPoolSize": 2000,
|
||||||
"CdnFullUrl": "https://<url or ip to your server>/cache/",
|
"CdnFullUrl": "https://<url or ip to your server>/cache/",
|
||||||
"FailedAuthForTempBan": 5,
|
"FailedAuthForTempBan": 5,
|
||||||
"TempBanDurationInMinutes": 30,
|
"TempBanDurationInMinutes": 30,
|
||||||
|
|||||||
Reference in New Issue
Block a user