adjustments to config and cleanup nuget, remove implicit usings

This commit is contained in:
Stanley Dimant
2022-08-23 11:21:21 +02:00
parent afcb268ccc
commit 2510cce711
23 changed files with 156 additions and 96 deletions

View File

@@ -66,7 +66,7 @@ namespace MareSynchronosServer.Hubs
IsForbidden = forbiddenFile != null,
Hash = hash.Key,
Size = hash.Value,
Url = _configuration["CdnFullUrl"] + hash.Key.ToUpperInvariant()
Url = new Uri(cdnFullUri, hash.Key.ToUpperInvariant()).ToString()
});
}

View File

@@ -23,10 +23,10 @@ namespace MareSynchronosServer.Hubs
private readonly AuthService.AuthServiceClient _authServiceClient;
private readonly FileService.FileServiceClient _fileServiceClient;
private readonly SystemInfoService _systemInfoService;
private readonly IConfiguration _configuration;
private readonly IHttpContextAccessor contextAccessor;
private readonly ILogger<MareHub> _logger;
private readonly MareDbContext _dbContext;
private readonly Uri cdnFullUri;
public MareHub(MetricsService.MetricsServiceClient metricsClient, AuthService.AuthServiceClient authServiceClient, FileService.FileServiceClient fileServiceClient,
MareDbContext mareDbContext, ILogger<MareHub> logger, SystemInfoService systemInfoService, IConfiguration configuration, IHttpContextAccessor contextAccessor)
{
@@ -34,7 +34,7 @@ namespace MareSynchronosServer.Hubs
_authServiceClient = authServiceClient;
_fileServiceClient = fileServiceClient;
_systemInfoService = systemInfoService;
_configuration = configuration;
cdnFullUri = new Uri(configuration.GetRequiredSection("MareSynchronos").GetValue<string>("CdnFullUrl"));
this.contextAccessor = contextAccessor;
_logger = logger;
_dbContext = mareDbContext;

View File

@@ -9,26 +9,14 @@
<ItemGroup>
<PackageReference Include="AspNetCoreRateLimit" Version="4.0.2" />
<PackageReference Include="Bazinga.AspNetCore.Authentication.Basic" Version="2.0.1" />
<PackageReference Include="Ben.BlockingDetector" Version="0.0.4" />
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
<PackageReference Include="Grpc.AspNetCore" Version="2.47.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.47.0" />
<PackageReference Include="Karambolo.Extensions.Logging.File" Version="3.3.1" />
<PackageReference Include="lz4net" Version="1.0.15.93" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.715">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.6" />
</ItemGroup>
<ItemGroup>

View File

@@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.Authorization;
using AspNetCoreRateLimit;
using Ben.Diagnostics;
using MareSynchronosShared.Authentication;
using MareSynchronosShared.Data;
using MareSynchronosShared.Protos;
@@ -45,17 +44,19 @@ namespace MareSynchronosServer
services.AddSingleton<IUserIdProvider, IdBasedUserIdProvider>();
services.AddTransient(_ => Configuration);
var mareConfig = Configuration.GetRequiredSection("MareSynchronos");
services.AddGrpcClient<AuthService.AuthServiceClient>(c =>
{
c.Address = new Uri(Configuration.GetValue<string>("ServiceAddress"));
c.Address = new Uri(mareConfig.GetValue<string>("ServiceAddress"));
});
services.AddGrpcClient<MetricsService.MetricsServiceClient>(c =>
{
c.Address = new Uri(Configuration.GetValue<string>("ServiceAddress"));
c.Address = new Uri(mareConfig.GetValue<string>("ServiceAddress"));
});
services.AddGrpcClient<FileService.FileServiceClient>(c =>
{
c.Address = new Uri(Configuration.GetValue<string>("StaticFileServiceAddress"));
c.Address = new Uri(mareConfig.GetValue<string>("StaticFileServiceAddress"));
});
services.AddDbContextPool<MareDbContext>(options =>
@@ -66,7 +67,7 @@ namespace MareSynchronosServer
builder.MigrationsAssembly("MareSynchronosShared");
}).UseSnakeCaseNamingConvention();
options.EnableThreadSafetyChecks(false);
}, Configuration.GetValue("DbContextPoolSize", 1024));
}, mareConfig.GetValue("DbContextPoolSize", 1024));
services.AddHostedService(provider => provider.GetService<SystemInfoService>());
@@ -92,8 +93,6 @@ namespace MareSynchronosServer
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseBlockingDetection();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();

View File

@@ -23,10 +23,12 @@
]
}
},
"DbContextPoolSize": 2000,
"CdnFullUrl": "https://<url or ip to your server>/cache/",
"ServiceAddress": "http://localhost:5002",
"StaticFileServiceAddress": "http://localhost:5001",
"MareSynchronos": {
"DbContextPoolSize": 2000,
"CdnFullUrl": "https://<url or ip to your server>/cache/",
"ServiceAddress": "http://localhost:5002",
"StaticFileServiceAddress": "http://localhost:5001"
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {