[FA-9] Postgres backing works

This commit is contained in:
gamer147
2025-11-20 13:53:58 -05:00
parent 0abb10bb00
commit 3250cf1467
8 changed files with 1508 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ using FictionArchive.Service.SchedulerService.Services;
using FictionArchive.Service.Shared.Extensions;
using FictionArchive.Service.Shared.Services.EventBus.Implementations;
using Quartz;
using Quartz.Impl.AdoJobStore;
namespace FictionArchive.Service.SchedulerService;
@@ -17,6 +18,12 @@ public class Program
builder.Services.AddHealthChecks();
builder.Services.AddTransient<JobManagerService>();
#region Database
builder.Services.RegisterDbContext<SchedulerServiceDbContext>(builder.Configuration.GetConnectionString("DefaultConnection"));
#endregion
#region Event Bus
builder.Services.AddRabbitMQ(opt =>
@@ -30,7 +37,16 @@ public class Program
builder.Services.AddQuartz(opt =>
{
opt.UseMicrosoftDependencyInjectionJobFactory();
opt.UsePersistentStore(pso =>
{
pso.UsePostgres(pgsql =>
{
pgsql.ConnectionString = builder.Configuration.GetConnectionString("DefaultConnection");
pgsql.UseDriverDelegate<PostgreSQLDelegate>();
pgsql.TablePrefix = "quartz.qrtz_"; // Needed for Postgres due to the differing schema used
});
pso.UseNewtonsoftJsonSerializer();
});
});
builder.Services.AddQuartzHostedService(opt =>
{
@@ -40,6 +56,12 @@ public class Program
#endregion
var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<SchedulerServiceDbContext>();
dbContext.UpdateDatabase();
}
app.UseHttpsRedirection();