-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure multiples schedules of the same job with different chains of dependent jobs are properly processed #124
Ensure multiples schedules of the same job with different chains of dependent jobs are properly processed #124
Conversation
a1f99b7
to
a4cee5c
Compare
a4cee5c
to
c5a17da
Compare
c5a17da
to
a7276b8
Compare
Locally I can't reproduce the hanging test, but when running via Github Codespace, it also sometimes hangs. Just doesn't show the current executed test. |
On it. |
7a3e76a
to
be7a083
Compare
Can't repro either. |
be7a083
to
1eafc1b
Compare
I'll try to reproduce via the Codespace. Just FYI: You can also use codespaces with 120 CPU hours for free. |
Thanks for the identification. I'll take a look at it tomorrow. |
Actually, couldn't resist. So I took a quick peek. The hanging problem seems unrelated to this PR as it can be reproduced on Codespaces against the |
Interesting! Thanks for the heads up! Well - probably it is fine if we tackle it on |
Tracked through #125 |
src/NCronJob/Registry/JobRegistry.cs
Outdated
@@ -19,7 +21,7 @@ internal sealed class JobRegistry | |||
public JobDefinition GetJobDefinition<T>() => allJobs.First(j => j.Type == typeof(T)); | |||
|
|||
public JobDefinition? FindJobDefinition(Type type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the "TODO" itself. In its current state we only have a jobdefinition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that context, how about replacing FirstOrDefault()
by SingleOrDefault()
?
This would enforce the expected intent of the design and would allow to not swallow potential issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a big fan of "fail fast". Do we have an option for v3
to throw an exception when we add a duplicate?
In v4 UseNCronJob
could be our savior - but not sure what can be done for v3.
If there isn't anything, maybe a custom exception might be more appropriate. Not sure what a user can do if he receives the InvalidOperationException
with "Sequence contains more than one element" message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've eventually only removed the TODO.
The code actually doesn't allow duplicates. In that context, Using FirstOrDefault()
or SingleOrDefault()
is similar.
However, the way the code deals with duplicates isn't uniform, from a user standpoint. A such, I've created #128 (which I think should be dealt with in the context of v4 as it will certainly generate a change the behavior).
1eafc1b
to
95f8209
Compare
95f8209
to
ce12546
Compare
ce12546
to
8fba306
Compare
Changelog has been updated as well. |
Good work! I will directly make a new release! |
Pull request description
This partly fixes #108 with regards to not properly honoring different dependent schedules.
However, this doesn't deal with the other broader concerns (for instance, how to selectively run an instant job targeting a specified configured schedule among other ones).
PR meta checklist
main
branch for codeCode PR specific checklist