-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
added support for seconds in NCronTab expressions #368
Conversation
Does it work? The |
Actually, no. Well, partially. This patch allows, one to be able to specify seconds in crontab expressions, and my test are all about that. Actual work is to get scheduler to process them in seconds not in minutes as you explained. In my stupidest hour, I've assumed that should be enough, but it actually is not. Now I've enabled "seconds" in scheduler and some other places. It is less than ideal (SQL polling interval is now .5 seconds when second resolution is enabled), but It looks like it is working. Today I will create another pull request for that change. I'm new to all this pull request, so please forgive me. |
QuickDoc: GlobalConfiguration.Configuration.UseSecondResolution() to enable it |
Don't worry, let's do it 😄 |
Is there any way to lower the number of resulting classes without loosing their simplicity? |
I think that second and minute throttling are the only cases, other invervals are unlikely be implemented. |
Oh, @edokan, can you also re-target this feature against the |
Hi, Here are my replies. We had outsourced a project that uses hangfire for scheduled jobs, which is pretty nice, but they set so jobs are scheduled to work on every 15 minutes.
we needed some jobs to be scheduled to run on every 15 seconds, and there is an issue (#167) for that waiting for about a year.
I think it is possible, but code may not be cleaner. Let me have a look.
It is possible, My first implementation used a lot less classes, then I refactored. Simplicity my not suffer that much
"minute" implementation covers 99.9% of cases, with "second" implementation, almost every case should be covered. I just did not want to leak to your implementation too much.
I will. |
Ok, will wait for the changes. Regarding to the "What is the purpose of this change? I don't think it is necessary.", I've asked it because "every second" functionality should not cause to change the |
{ | ||
public abstract class SchedulerResolution | ||
{ | ||
private static SchedulerResolution _current = new MinuteSchedulerResolution(); |
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.
Not a big deal, but I don't like that the abstract class is aware of its inheritors.
Hi @edokan! Any news on this PR? |
Hi Guys. Is there any progress with that? I would like to use hangfire to pull amazon simple queue service every 20 seconds. |
+1 :) We also have a need for less than minute recurring jobs. |
+1 Hi! I would also like to use hangfire for recurring jobs every 30 seconds. |
+1 |
Use background processes appeared in Hangfire 1.5.0 to handle sub-minute intervals. Recurring jobs currently too slow to handle such intervals, since all of them are iterated on each run, harnessing the storage. Their implementation will be changed in Hangfire 2.0, opening a way to use seconds in intervals. |
Hello my friends, today I have an activity that is requiring recurring processes every 20 seconds. I know this item stayed for version 2.0, but is there any way I can implement it myself in my application? |
@Jedarc you can register a custom BackgroundProcess and set the delay inside it to 20 seconds. I do this for all my jobs which needs to run continuously/more often than ever minute. Create a class that implements |
@burningice2866 many thanks for the quick response, would you have any examples of this implementation, please? The documentation is a bit obscure to me, and I can not imagine how I could implement the interface to allow my recurring jobs to run within a set amount of seconds. I looked for examples, but I still did not succeed progress. |
@Jedarc The interface has a single method where you implement your logic. The easiest is to wrap your code in a So something like
|
added support for seconds in NCronTab expressions.
Needed to update NCronTab and CronExpressionDescriptor to latest versions to ensure seconds part is compatible. Seconds support is kinda hacky.
Added some unit tests.