Closed jainsahab closed 4 years ago
Providing wrapper function over Failsafe's timeout functionality, Create a timeout using deftimeout
macro and use one of the get-with-timeout
, run-with-timeout
, get-async-with-timeout
or run-async-with-timeout
to exucute and retrieve the result.
(ns diehard.example
(:require [diehard.core :refer :all]
[diehard.timeout :as dt])
(:import (java.time Duration)))
(defn -main []
(deftimeout timeout (Duration/ofSeconds 4) {:on-success (fn [_]
(println "executed successfully"))})
(println (dt/get-with-timeout timeout (fn []
(Thread/sleep 3000)
"result")))
(dt/run-with-timeout timeout (fn []
(Thread/sleep 3000)
(println "result"))))
Apart from get-with-timeout
and run-with-timeout
, this library also offers get-async-with-timeout
and run-async-with-timeout
to execute a block asynchronously against a timeout.
Hi @sunng87 , I am done with the #27 solution. Could you please review it and let me know if there is any feedback from your side? Thanks. :)
Thanks @jainsahab ! This looks good to me overall. I will merge it for now. But I may update some of apis before final release.
Thanks @sunng87 , Waiting for the release of latest version. :)
Excellent work! Waiting for release +1 !!
Fix for #27