Liking cljdoc? Tell your friends :D

hara.function.procedure


+default-cacheclj

(+default-cache ??)
?? invalid arglists:
()

default cache for storing procedure results

default cache for storing procedure results
raw docstring

+default-settings+clj


defprocedurecljmacro

(defprocedure name config & 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-intern-procedureclj

(invoke-intern-procedure name config body)
(invoke-intern-procedure _ name config body)

creates the form for defining the procedure

(invoke-intern-procedure '-hello- {:mode :sync} '([] (Thread/sleep 1000)))

creates the form for defining the procedure

(invoke-intern-procedure '-hello- {:mode :sync} '([] (Thread/sleep 1000)))
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

procedure-displayclj

(procedure-display proc)

displays the procedure

displays the procedure
raw docstring

procedure-invokeclj

(procedure-invoke {: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

procedure-killclj

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

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

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

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

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

procedure-running?clj

(procedure-running? {:keys [thread] :as p})

checks if a procedure is running

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

(procedure-running? -proc-) => true

checks if a procedure is running

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

(procedure-running? -proc-)
=> true
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