HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.33k stars 1.69k forks source link

MinuteInterval will be deprecated in version 2.0 #1417

Open jgathairu opened 5 years ago

jgathairu commented 5 years ago

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

mareklinka commented 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} * * * *"

softlion commented 5 years ago

So there is no helper to create these cryptics error prone strings ? This is not a progress ... one step back...

mareklinka commented 5 years ago

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.

softlion commented 5 years ago

A builder class for cron would be nice. I thought you replaced these methods with a builder class. But no.

mareklinka commented 5 years ago

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.

natiki commented 5 years ago

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 ;-)

cazangabriel commented 4 years ago

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..

emilkhamitov commented 3 years ago

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.

biapar commented 3 years ago

Error: Wrong number of parts in the 0 20 1 * cron expression, you can only use 5 or 6 (with seconds) part-based expressions.

DanielOlsenRiver commented 3 years ago

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.

54mu3l commented 2 years ago

Anything new on this issue?

I completely agree readable code is a must!

marius-haugan commented 2 years ago

How anyone in their right mind can make something like "DayInterval(14)" obsolete for "0 0 14 * 0" is beyond my understanding. Extremely silly..

pouyaSamie commented 1 year ago

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.

cruentusmors commented 1 month ago

definitely a step backwards