-
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
Deal with duplicates in a uniform manner #128
Comments
Hmm good catch. Would be nice if we can even do this on |
I can remember we had some discussion month ago about this (#79). One possible solution was just to "ignore" the fact and use something like a So the question is whether or not this is an "exceptional" case in which the system can't behave properly anymore. |
I would still argue: Let's drop duplicates, create a warning and let the user decide what's going on. ServiceCollection.AddNCronJob(n => n
.AddJob<SimpleJob>(p => p.WithCronExpression("* * * * *").WithName("Name"))
.AddJob<OtherUnrelatedJob>(p => p.WithCronExpression("1 1 * * *").WithName("Name"))); That has to fail.The system can not operate and recover if we encounter this situation. |
Sorry for the spam. I just checked, we are already dropping duplicates. So the only thing would be to at least print a warning that we detected a duplicate. |
Thanks for the pointer. With regards to the following, those are clearly two different job definitions.
Whereas I can't find a proper use case to allow
As no one has complained about it, I'd say, keep v3 as is from a behavioral standpoint (and log a warning) and throw in v4. |
And I do agree that we need names being unique, as those names will certainly play a role in the disambiguation all the weird registration corner cases from #108. |
When I started that library - I had a very very small use case for it. Very interesting where we got here :D In any case - for sure I will log a warning for v3 and make myself some thoughts about throwing. |
:D This lib fills a need without going full blown Enterprise-y. |
With regards to throwing for v4, below my two cents: There are two use cases for registering new jobs:
How about:
|
Hmm good question. We could also offer a TryRegister or a configuration on the runtime registry. |
Going further, maybe a Then the user would be free to either log the exception, feed it to an Obervability container or just throw it... |
For the time being this seems to be the most straightforward way. In any case, I will disallow registering multiple jobs at the same time. |
I do agree! |
Done in #129 |
Doesn't cringe:
vs
Fails with
InvalidOperationException
The code does a lot to avoid duplicated jobDefinitions.
However, the API is a tad inconsistent here with regards to its behavior.
I'd be in favor of always failing.
The text was updated successfully, but these errors were encountered: