We have a .net core app with the following folder / onion structure:
WidgetApp -> Core -> Application -> JobAutoStarter -> JobAutoStarter.cs
WidgetApp -> Core -> Domain -> Entities
WidgetApp -> Infrastructure -> Hangfire -> WidgetJobs -> Job1 (hangfire job logic)
WidgetApp -> Infrastructure -> Hangfire -> WidgetJobs -> Job2
WidgetApp -> Infrastructure -> Persistence -> WidgetDb
WidgetApp -> Presentation -> (various Apis)
The JobAutoStarter is a new feature we are going to add to our app. When the app starts, the first thing it will do is check the db for a list of Hangfire jobs that need to be auto started (based on other domain specific criterion and not just what's configured in hangfire This is why the class right now is in the application layer) If it finds a job that should be started, then the JobAutoStarter class currently includes methods like:
try
{
AssignHangfireJobNumber(jobDetails);
UpdateHangfireJobInstance(jobDetails);
ScheduleJobInHangfire(jobDetails);
UpdateAssignedHangfireJobNumber(jobDetails);
}
catch (Exception ex)
{
}
I don't really want the application layer to know so much about the inner workings of Hangfire. But, in an onion, I don't think it's good design for the application layer to "know" about stuff in Infrastructure either, if I understand correctly. I was thinking of creating for example:
WidgetApp -> Infrastructure -> Hangfire -> Common -> JobAssigner.cs
WidgetApp -> Infrastructure -> Hangfire -> Common -> JobInstanceUpdater.cs
WidgetApp -> Infrastructure -> Hangfire -> Common -> JobScheduler.cs
But not sure if that would break my onion or not. So Just looking for some suggestions on how to organize this code.


