Open maacl opened 2 weeks ago
Yes - so 100% something I plan to do. Just waiting until i've built to a sufficiently motivating example.
The key will be to be able to wait for all the background jobs to "settle."
Basically the following
(defn wait-for-background-jobs
[db & {:keys [max-duration duration-between-polls]
:or {max-duration (Duration/ofMillis 30000)
duration-between-polls (Duration/ofMillis 250)}}]
(loop [time-taken (Duration/ofMillis 0)]
(let [{:keys [count]} (jdbc/execute-one! db ["SELECT COUNT(*) as count FROM proletarian.job"])]
(when (> (compare time-taken max-duration) 0)
(throw (ex-info "Background jobs took too long"
{:time-taken time-taken
:max-duration max-duration})))
(when-not (zero? count)
(^[Duration] Thread/sleep duration-between-polls)
(recur (.plus time-taken duration-between-polls))))))
Keep this issue open so I remember to loop back to it soon. ATM my immediate priority is user auth(n/z) since thats a pre-req to making an actually interesting demo
Right now jobs are not running when using test.system. This prevents testing of triggers.