Open jgathairu opened 5 years ago
Looking into the code, the MinuteInterval
just does $"*/{interval} * * * *"
:
https://github.com/HangfireIO/Hangfire/blob/9cd09f38fa97e4c2dd48f6097985fd2b48b4568e/src/Hangfire.Core/Cron.cs#L231
Therefore
Cron.MinuteInterval(int.Parse(jobScheduler.Duration));
should be equivalent to
$"*/{jobScheduler.Duration} * * * *"
So there is no helper to create these cryptics error prone strings ? This is not a progress ... one step back...
Well, it's just cron expressions. While I agree they are not very readable to anyone who doesn't work with Linux regularly, there are some tools to help with them. E.g. crontab.guru. I haven't looked, but there might be some good nuget packages for creating these as well.
A builder class for cron would be nice. I thought you replaced these methods with a builder class. But no.
You might notice I'm not involved with this repository/library in any capacity. Found this issue a while back, wanted to share a workaround. You will need to wait for the official maintainers to get any APIs changed to your liking.
When I looked into this I ended up using https://github.com/bradymholt/cron-expression-descriptor/issues/123#issuecomment-532056815 (As HF ultimately uses https://github.com/bradymholt/cron-expression-descriptor) and that maintainer also did not want to add a builder ;-)
So there is no helper to create these cryptics error prone strings ? This is not a progress ... one step back...
hey! here's an idea, migrate from hangfire to azure functions..
Tried to use CronEspresso
string cronExpression = CronEspresso.NETCore.CronGenerator.GenerateMinutesCronExpression(5);
Result: System.ArgumentException: 'CRON expression is invalid. Please see the inner exception for details.
Parameter name: cronExpression'
Inner Exception: CronFormatException: Wrong number of parts in the 0 0/5 * 1/1 * ? *
cron expression, you can only use 5 or 6 (with seconds) part-based expressions.
Error: Wrong number of parts in the 0 20 1 *
cron expression, you can only use 5 or 6 (with seconds) part-based expressions.
Readable code is a huge must have. -> Making something that requires working with Linux a requirement, and ontop -> Having to use 3rd party tools to make / figure out what a cron expression means.
I think this is not a good solution.
The fact that there is even a discussion going on, on this issue about how these cron expressions work, just emphasizes my concern.
Readable Code > Reverting to old standards. -> If we just continued to do "like we've always done", we never move forward.
Anything new on this issue?
I completely agree readable code is a must!
How anyone in their right mind can make something like "DayInterval(14)" obsolete for "0 0 14 * 0" is beyond my understanding. Extremely silly..
now all of us have to write our own Builder class because Hangfire does not support 6-part cron either. that is really a big problem with a library like Hangfire. Quartz.net has a good builder and most people don't want to use hard-coded crons. we as the community really needed that also I was hoping we get an extended version of Cron class as a real builder class.
definitely a step backwards
What's the replacement. Don't see a good option from the suggestions provided. I had this return Cron.MinuteInterval(int.Parse(jobScheduler.Duration)); and now I am using return Cron.Hourly(int.Parse(jobScheduler.Duration)); but that does not represent what I want which is a job that runs after every 30 minutes and NOT 30 minutes into the hour