Closed linkdotnet closed 6 months ago
@falvarez1 I am more and more inclined to merge that PR. It basically doesn't only add the feature but also
JobQueue
and QueueWorker
).Also, I renamed a few things, but I will annotate a few things that might need some polishing.
One thing that bothered me in this PR I’d that we don’t distinguish between a JobDefinition and a JobRun. while not crucial now, i do feel more and more pressure to have those two objects
One thing that bothered me in this PR I’d that we don’t distinguish between a JobDefinition and a JobRun. while not crucial now, i do feel more and more pressure to have those two objects
Yes I agree we need a clear definition and needs to be distinct, this is necessary for the observability for dashboard etc.
Both Jobs and a Job Runs need their own definition.
I will pick the good parts here and close the PR. The PR did too much anyway.
Currently this is more of an extensive draft rather than a PR. Basically, this PR tackles #46 to a greater extent.
The Core Idea
The idea is to define job dependencies like this:
So, one job type can define 0..n dependencies that will run after the job has finished. We only distinguish between "success" and "faulted".
The newly dependent job will get the output of the principal job (
ParentOutput
) as part of theJobExecutionContext
. I was thinking of widening that to have the following API:At least that seems less arbitrary in terms of what we do and don't push down to dependent jobs.
In theory the user can define a job graph as such:
RunJob<TJob>
inside oneWhen
clause - chaining multiple jobs and pushing multiple jobs into the queue.AddJob
withWhen(s => s.RunJob)
to chain them further.I do think that is the right balance between over flexibility and a solution that is too simple.
Refactorings
In the same term, I refactored some of our types. I extracted some of the logic and moved some bits here and there. Mainly, I introduced a
JobQueue
, which is the sticky part between theQueueWorker
(formerlyCronScheduler
) and theJobExecutor
).Current open topics
RunJob
will not automatically be registered. Still, the user has to callAddJob
somewhere. Maybe we want to change that as it seems arbitrary.