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

Introduce start-delay #10

Open
d-t-w opened this issue Oct 19, 2021 · 0 comments
Open

Introduce start-delay #10

d-t-w opened this issue Oct 19, 2021 · 0 comments

Comments

@d-t-w
Copy link
Member

d-t-w commented Oct 19, 2021

We can start a simple schedule anytime (e.g. every 60s) but we don't currently support starting a simple schedule with a delay. We do support starting at a specific point in time, but a delay is much more useful.

You can get around this in code, e.g. this starts a 1m recurring job that begins in one minute.

Would be better to just do this from config with :start-delay

  (let [period  (* 1 60000)
        trigger ^TriggerBuilder (cronut/trigger-builder {:type      :simple
                                                         :interval  period
                                                         :time-unit :millis
                                                         :repeat    :forever
                                                         :misfire   :fire-now})
        start   (Date. ^Long (+ (System/currentTimeMillis) period))] ;; introduce cronut start-delay configuration
    {:job     (reify Job
                (execute [_ _]
                  (try (do-thing) (catch Exception _ (log/error "thing error")))))
     :trigger (.startAt trigger start)}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant