Removed hangfire. Added TickerQ
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
using Hangfire;
|
||||
using Hangfire.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moonlight.ApiServer.Database;
|
||||
|
||||
namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterHangfire()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddHangfire((provider, configuration) =>
|
||||
{
|
||||
configuration.SetDataCompatibilityLevel(CompatibilityLevel.Version_180);
|
||||
configuration.UseSimpleAssemblyNameTypeSerializer();
|
||||
configuration.UseRecommendedSerializerSettings();
|
||||
configuration.UseEFCoreStorage(() =>
|
||||
{
|
||||
var scope = provider.CreateScope();
|
||||
return scope.ServiceProvider.GetRequiredService<CoreDataContext>();
|
||||
}, new EFCoreStorageOptions());
|
||||
});
|
||||
|
||||
WebApplicationBuilder.Services.AddHangfireServer();
|
||||
|
||||
WebApplicationBuilder.Logging.AddFilter(
|
||||
"Hangfire.Server.BackgroundServerProcess",
|
||||
LogLevel.Warning
|
||||
);
|
||||
|
||||
WebApplicationBuilder.Logging.AddFilter(
|
||||
"Hangfire.BackgroundJobServer",
|
||||
LogLevel.Warning
|
||||
);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseHangfire()
|
||||
{
|
||||
if (WebApplication.Environment.IsDevelopment())
|
||||
WebApplication.UseHangfireDashboard();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
34
Moonlight.ApiServer/Startup/Startup.TickerQ.cs
Normal file
34
Moonlight.ApiServer/Startup/Startup.TickerQ.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moonlight.ApiServer.Database;
|
||||
using Moonlight.ApiServer.Implementations;
|
||||
using TickerQ.DependencyInjection;
|
||||
using TickerQ.EntityFrameworkCore.DependencyInjection;
|
||||
|
||||
namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterTickerQ()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddTickerQ(builder =>
|
||||
{
|
||||
builder.SetExceptionHandler<TickerExceptionHandler>();
|
||||
|
||||
builder.AddOperationalStore<TickerDataContext>(optionBuilder =>
|
||||
{
|
||||
optionBuilder.CancelMissedTickersOnApplicationRestart();
|
||||
});
|
||||
});
|
||||
|
||||
WebApplicationBuilder.Services.AddDbContext<TickerDataContext>();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseTickerQ()
|
||||
{
|
||||
WebApplication.UseTickerQ();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public partial class Startup
|
||||
await RegisterDatabase();
|
||||
await RegisterAuth();
|
||||
await RegisterCors();
|
||||
await RegisterHangfire();
|
||||
await RegisterTickerQ();
|
||||
await HookPluginBuild();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public partial class Startup
|
||||
await UseCors();
|
||||
await UseBase();
|
||||
await UseAuth();
|
||||
await UseHangfire();
|
||||
await UseTickerQ();
|
||||
await HookPluginConfigure();
|
||||
|
||||
await MapBase();
|
||||
|
||||
Reference in New Issue
Block a user