Skip to content

Commit

Permalink
Check persistance mode before preparating database
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramazan Yilmaz committed Aug 6, 2024
1 parent 96899fa commit b701e22
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/BulkRename/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ private void ConfigurePersistance(IServiceCollection services)
}

public async Task Configure(WebApplication app)
{
ConfigureLogger();
await PreparateDatabase(app);
}

private void ConfigureLogger()
{
var seqUrl = Configuration[ConfigurationNameConstants.SEQ_URL];

Expand All @@ -78,11 +84,18 @@ public async Task Configure(WebApplication app)
.WriteTo.File(path: logPath, rollingInterval: RollingInterval.Day)
.WriteTo.Console().CreateLogger();
}
}

var connectionTimeOut = GetConnectionTimeOut();
var preparationDatabase = app.Services.GetService<PreparationDatabase>();
var task = preparationDatabase!.PreparatePopulation(app, connectionTimeOut);
await task;
private async Task PreparateDatabase(WebApplication app)
{
var persistanceMode = Configuration.GetValue<PersistanceMode>(nameof(PersistanceMode));
if (persistanceMode == PersistanceMode.Database)
{
var connectionTimeOut = GetConnectionTimeOut();
var preparationDatabase = app.Services.GetService<PreparationDatabase>();
var task = preparationDatabase!.PreparatePopulation(app, connectionTimeOut);
await task;
}
}

private void SetConnectionString()
Expand Down

0 comments on commit b701e22

Please sign in to comment.