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

Optionally allow first_at to be set in the past #342

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

austinarbor
Copy link
Contributor

First off - thanks for creating and maintaining this great library, my team has been using it for many years. However, one thing that has consistently plagued us throughout the years is the ArgumentError thrown if first_at is in the past. We use rufus-scheduler via resque-scheduler, and unfortunately we have seen wildly inconsistent performance when saving new schedules (sometimes up to 2 minutes between when we save and when rufus processes the schedule). Because of this, even if we pass in a first_at in the future, when rufus processes the job it is no longer in the future and throws an error and crashes the scheduler. As a workaround, we have had to add in an an artificial buffer that if our desired first_at is less than 2 minutes from now, set it to nil instead so rufus does not throw an error.

However, this behavior isn't entirely desirable since it can skew the execution time of our schedules. We'd much prefer to not to have to handle the buffer on our side, and pass in an option which will accept a first_at in the past and set it to :now if it is.

Would you be open to allowing this option? This would GREATLY help us. The amount of time we have spent implementing various workarounds is truly inconceivable.

Note: Ruby is not one of my most proficient languages so apologies in advance. Feel free to edit/change as needed.

@jmettraux jmettraux self-assigned this Jun 8, 2023
@jmettraux jmettraux merged commit 213bcf2 into jmettraux:master Jun 9, 2023
7 checks passed
@jmettraux
Copy link
Owner

@austinarbor Thanks a lot! It's merged, I will just re-indent the spec, no complaints. I will release a 3.9.1 with it soon.

jmettraux added a commit that referenced this pull request Jun 9, 2023
jmettraux added a commit that referenced this pull request Jun 9, 2023
@austinarbor
Copy link
Contributor Author

@jmettraux thank you!

@jmettraux
Copy link
Owner

You're welcome! rufus-scheduler 3.9.1 released

@austinarbor austinarbor deleted the allow-first-at-in-past branch June 9, 2023 17:09
@austinarbor
Copy link
Contributor Author

austinarbor commented Jun 9, 2023

@jmettraux should I have set @first_at to n1 instead of n0 ? I'm not sure how I missed it before, but the line above my change has this: @first_at = n1 if @first_at >= n0 && @first_at < n1 which seems like n1 was a better choice than n0. If you don’t think it will matter then I am happy in either case

@jmettraux
Copy link
Owner

@austinarbor Hello, I think it's OK like this. If you spot anything wrong in production please tell me. Have a nice week-end, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants