Liking cljdoc? Tell your friends :D

hara.concurrent.procedure


*default-cache*clj


*default-settings*clj


defprocedureclj/smacro

(defprocedure name defaults & body)

defining a procedure

(defprocedure hello {:mode :sync} [] (Thread/sleep 1000) :DONE)

(defprocedure print-hello {:id-fn :timestamp :arglist [:timestamp :params :instance] :params {:b 2}} [t params instance] (println "INSTANCE: " instance) (Thread/sleep 500) (println "ENDED" t))

defining a procedure

(defprocedure hello {:mode :sync}
  []
  (Thread/sleep 1000)
  :DONE)

(defprocedure print-hello
  {:id-fn :timestamp
   :arglist [:timestamp :params :instance]
   :params {:b 2}}
  [t params instance]
  (println "INSTANCE: " instance)
  (Thread/sleep 500)
  (println "ENDED" t))
raw docstring

invoke-baseclj

(invoke-base instance args)

constructs a standard procedure

(def proc {:handler + :result (promise)})

(invoke-base proc [1 2 3])

@(:result proc) => {:type :success, :data 6}

constructs a standard procedure

(def proc {:handler +
           :result (promise)})

(invoke-base proc [1 2 3])

@(:result proc)
=> {:type :success, :data 6}
raw docstring

invoke-procedureclj

(invoke-procedure {:keys [id-fn handler arglist time] :as procedure} & args)

the full invocation for the procedure, incorporating middleware and retry

the full invocation for the procedure, incorporating middleware and retry
raw docstring

killclj

(kill {:keys [registry name id]})

kills a running procedure (def proc ((procedure {:name "hello" :id :1 :handler (fn [] (Thread/sleep 1000000000))} [])))

(Thread/sleep 100) (kill proc) => true

kills a running procedure
(def proc ((procedure {:name "hello"
                       :id :1
                       :handler (fn [] (Thread/sleep 1000000000))} [])))

(Thread/sleep 100)
(kill proc)
=> true
raw docstring

max-inputsclj

(max-inputs func num)

finds the maximum number of inputs that a function can take

(max-inputs (fn ([a]) ([a b])) 4) => 2

(max-inputs (fn [& more]) 4) => 4

(max-inputs (fn ([a])) 0) => throws

finds the maximum number of inputs that a function can take

(max-inputs (fn ([a]) ([a b])) 4)
=> 2

(max-inputs (fn [& more]) 4)
=> 4

(max-inputs (fn ([a])) 0)
=> throws
raw docstring

procedureclj

(procedure tk arglist)

creates a procedure for computation

@((procedure {:name "ID" :handler (fn [id params instance] ; (println (-> instance :retry :count)) (if (= 5 (-> instance :retry :count)) (-> instance :retry :count) (throw (Exception.)))) :retry {:handle [{:on #{Exception} :apply (fn [state e]) :limit (fn [state count]) :wait (fn [state count])}] :count 0 :state {:a 1 :b 2} :limit 10 :wait 100}} [:id :params :instance]) "ID" {} {:mode :async :cached false}) => 5

creates a procedure for computation

@((procedure {:name "ID"
              :handler (fn [id params instance]
                         ; (println (-> instance :retry :count))
                         (if (= 5 (-> instance :retry :count))
                           (-> instance :retry :count)
                           (throw (Exception.))))
             :retry {:handle [{:on #{Exception}
                                :apply   (fn [state e])
                                :limit   (fn [state count])
                                :wait    (fn [state count])}]
                      :count 0
                      :state  {:a 1 :b 2}
                      :limit 10
                      :wait  100}}
            [:id :params :instance])
  "ID" {} {:mode :async :cached false})
=> 5
raw docstring

wrap-exceptionclj

(wrap-exception f)

creates a handler for retrying computation

creates a handler for retrying computation
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close