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

Cron syntax #40

Closed
decebals opened this issue Nov 7, 2018 · 7 comments
Closed

Cron syntax #40

decebals opened this issue Nov 7, 2018 · 7 comments
Milestone

Comments

@decebals
Copy link

decebals commented Nov 7, 2018

First of all, congratulations for this library.
I want to ask if it's a possibility to use a Cron syntax when I schedule a task/job.

@kagkarlsson
Copy link
Owner

Thanks! I want to be able to support cron-patterns, and ideally we would use some existing cron-library for it, but my problem is that I do not want to add a dependency for it. So there are a few options, but I am currently undecided:

  • Write our own cron-parser
  • Depend on an existing library, but do so via a db-scheduler-contrib or db-scheduler-addons artifact
  • Depend on an existing library, and add it to the db-scheduler jar via shading

For now you can come reasonably close using Schedules.daily(LocalTime... times).

May I ask what type of cron-pattern do you have need for?

@decebals
Copy link
Author

decebals commented Nov 8, 2018

... my problem is that I do not want to add a dependency for it.

Very good. This is also my approach in my projects.

... there are a few options, but I am currently undecided:

  • Write our own cron-parser
  • Depend on an existing library, but do so via a db-scheduler-contrib or db-scheduler-addons artifact
  • Depend on an existing library, and add it to the db-scheduler jar via shading

Personal, I think that variant three (3) is the best (no need to invest time in cron parser). You can mark the dependency to cron-parser library as optional. When you need cron syntax you must include the cron-parser dependency.

May I ask what type of cron-pattern do you have need for?

For the moment I need to run at a time, only on workday (from Monday to Friday).

I think that add support for cron syntax is a nice feature. In the same time I like to preserve minimalist aspect (very few dependency and small size) of library. In this context it's necessary a cron-parser library with the same profile like this (minimalist and active maintained) .

@kagkarlsson
Copy link
Owner

Do you know of any good cron-libraries?

@decebals
Copy link
Author

decebals commented Nov 8, 2018

Do you know of any good cron-libraries?

A candidate could be cron-utils.

Related to my requirement, I think that for the moment I can check in the execution-handler method if the current day is a workday or not. It's not ideal but I think that it works.

By the way, another idea about where to put the new feature (support cron syntax) is to convert your project in a multi modules Maven project and to add a new cron module.

@kagkarlsson
Copy link
Owner

Ok, will look into it.

Instead of checking in the execution-handler method for workday, you could just write your own implementation of the Schedule interface.

@decebals
Copy link
Author

decebals commented Nov 9, 2018

Instead of checking in the execution-handler method for workday, you could just write your own implementation of the Schedule interface.

I will try. I want to schedule some tasks from Monday to Friday between 9 AM and 17 PM with a period of 10 minutes (eventually with small delay). I hope that is possible.

@kagkarlsson
Copy link
Owner

Implemented in PR #56

@kagkarlsson kagkarlsson added this to the 5.1 milestone Mar 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants