cronut icon indicating copy to clipboard operation
cronut copied to clipboard

Introduce start-delay

Open d-t-w opened this issue 3 years ago • 0 comments

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)}))

d-t-w avatar Oct 19 '21 10:10 d-t-w