mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-13 06:47:54 +02:00
[postgres-Server-V2] feat(Jobs): Instead of passing context to each job, pass service provider and let the job create its own context
This commit is contained in:
@ -43,8 +43,11 @@ public abstract class Job
|
||||
RecurrenceMs = recurrenceMs;
|
||||
}
|
||||
|
||||
public IEnumerable<Job> Run(PgsqlContext context)
|
||||
public IEnumerable<Job> Run(IServiceProvider serviceProvider)
|
||||
{
|
||||
using IServiceScope scope = serviceProvider.CreateScope();
|
||||
PgsqlContext context = scope.ServiceProvider.GetRequiredService<PgsqlContext>();
|
||||
|
||||
this.state = JobState.Running;
|
||||
IEnumerable<Job> newJobs = RunInternal(context);
|
||||
this.state = JobState.Completed;
|
||||
|
Reference in New Issue
Block a user