Skip to content

Add optional date bounds to recurring job#952

Open
rfvgyhn wants to merge 4 commits intoHangfireIO:devfrom
rfvgyhn:datebounds
Open

Add optional date bounds to recurring job#952
rfvgyhn wants to merge 4 commits intoHangfireIO:devfrom
rfvgyhn:datebounds

Conversation

@rfvgyhn
Copy link
Copy Markdown

@rfvgyhn rfvgyhn commented Jul 26, 2017

This PR supersedes #939. I realized there's a dev branch that already has cronos merged. I went ahead and applied the same logic from the previous PR into the dev branch.

  • New overloads are added to RecurringJob.AddOrUpdate to allow for specifying a start and/or end date in UTC. Specifying these dates would queue new jobs only if the cron expression is matched and this run falls within the date bounds (inclusive).
  • Specifying start and or end date creates an allowable window for jobs to be queued. Null start implies queue immediately like existing recurring jobs. Null end implies queue forever.
  • Start and end dates are stored in the recurring job dictionary which, in sql server, end up in the Hash table. I haven't tested with Redis but I assume the serializer automatically handles it just like the it did for sql server.
  • I think there's no impact on current users since the two fields are optional. The job scheduler checks if start/end dates have a value. If not, the existing logic is used.

Questions:

  • Regarding @burningice2866's comment, adding explicit overloads for start and end dates results in 48 overloads for AddOrUpdate. Would it be better to create a new method (e.g. AddOrUpdateBounded) that uses optional params or is that many overloads OK?
  • Regarding @aidmsu's comment and my response (point 1), I have made it so the dates must already be in UTC. Is there a scenario where that wouldn't work?
  • Does the UI portion need to be a part of this PR or can/should it be a part of another?
  • What are the thoughts on my previous comments(point 2) about UI?

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jul 26, 2017

Codecov Report

Merging #952 into dev will decrease coverage by 0.35%.
The diff coverage is 41.23%.

Impacted Files Coverage Δ
src/Hangfire.Core/RecurringJob.cs 0% <ø> (ø) ⬆️
src/Hangfire.Core/BoundedRecurringJob.cs 0% <0%> (ø)
src/Hangfire.Core/RecurringJobOptions.cs 100% <100%> (ø) ⬆️
src/Hangfire.Core/RecurringJobManagerExtensions.cs 84.61% <76.92%> (-7.7%) ⬇️
src/Hangfire.Core/Server/RecurringJobScheduler.cs 86.11% <89.47%> (+2.77%) ⬆️
src/Hangfire.Core/RecurringJobManager.cs 93.15% <91.66%> (-0.3%) ⬇️
src/Hangfire.Core/States/ScheduledState.cs 100% <0%> (ø) ⬆️
src/Hangfire.Core/States/EnqueuedState.cs 100% <0%> (ø) ⬆️
src/Hangfire.Core/States/AwaitingState.cs 0% <0%> (ø) ⬆️
src/Hangfire.Core/States/ProcessingState.cs 95% <0%> (ø) ⬆️
... and 5 more

@ahanley
Copy link
Copy Markdown

ahanley commented Jul 27, 2017

I commented in a previous ticket but thought i'd comment here as well. Joe Coutcher has an implementation of this you should look at https://github.com/jcoutch/Hangfire.RecurringDateRange

@rfvgyhn
Copy link
Copy Markdown
Author

rfvgyhn commented Aug 7, 2017

@odinserj @aidmsu @burningice2866 Any thoughts/feedback? I know the codecov check failed but the fix for that depends on keeping the 48 overloads or moving to a different method name with optional params.

@burningice2866
Copy link
Copy Markdown
Contributor

I personally like the idea of having a new RecurringDateRangeJob class used for scheduling recurring jobs with a start and end date. That way you don't need to pollute the existing RecurringJob class with tons of new overloads.

@rfvgyhn
Copy link
Copy Markdown
Author

rfvgyhn commented Aug 25, 2017

I moved the RecurringJob overloads to their own BoundedRecurringJob class. Any feedback is appreciated.

@burningice2866
Copy link
Copy Markdown
Contributor

I like it!

@rfvgyhn
Copy link
Copy Markdown
Author

rfvgyhn commented Aug 28, 2017

On a somewhat related note, the travis build failed and it looks like mono crashed right after running unit tests. Does that indicate a problem with the unit tests or an one-off issue with the build? Can the travis build be run again without having to push a new commit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants