[FA-9] Postgres backing works
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user