Skip to content
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

Why are the Interval functions being removed from Cron.cs? #1779

Open
RichardNobel opened this issue Dec 10, 2020 · 1 comment
Open

Why are the Interval functions being removed from Cron.cs? #1779

RichardNobel opened this issue Dec 10, 2020 · 1 comment

Comments

@RichardNobel
Copy link

Why are the MinuteInterval, HourInterval, DayInterval and MonthInterval functions considered Obsolete?

"Please use Cron expressions instead. Will be removed in 2.0.0"

In my opinion, it makes the code easier to read with MinuteInterval(15) instead of a string notation "*/15 * * * * ".

Of course I can copy these (or create similar) functions in my own project/library.

But is there a specific reason why they need to be removed from Hangfire.Core?

@BenJenkinson
Copy link

Hi @RichardNobel,

Issue #1041 describes the reason they were marked as obsolete. I've quoted it below:

Neither of these methods works correctly, when the specified interval is not a multiple of the corresponding field's range length (max-min). For example, when we are using Cron.HourInterval(10), we will not get the documented every 10 hours semantic, instead we'll get the following occurrences:

Nov 6, 00:00
Nov 6, 10:00
Nov 6, 20:00 
Nov 7, 00:00

Time interval between the last two entries is only 4 hours and violates what's written in the method's name and in its comments. Cron expressions don't allow to specify "every N" recurring intervals in general, and other methods should be used instead of confusing methods.

staviloglu added a commit to staviloglu/Hangfire that referenced this issue Nov 24, 2022
Updated MinuteInterval & HourInterval methods to make them available (not obselete) again.

Added defensive code against interval value to get rid of the problem described in HangfireIO#1041 

Also related:
HangfireIO#1054
HangfireIO#1779
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants