tweaks
This commit is contained in:
parent
5a2f68c1ea
commit
9d4b853e8f
2 changed files with 8 additions and 5 deletions
|
|
@ -348,8 +348,7 @@ function to invoke a pod var with callbacks.
|
||||||
|
|
||||||
The arguments to `babashka.pods/invoke` are:
|
The arguments to `babashka.pods/invoke` are:
|
||||||
|
|
||||||
- a pod identifier string, either explicitly set as `pod-id` in `describe`, or
|
- a pod identifier string derived from the first described namespace.
|
||||||
derived from the first described namespace.
|
|
||||||
- the symbol of the var to invoke
|
- the symbol of the var to invoke
|
||||||
- the arguments to the var
|
- the arguments to the var
|
||||||
- an opts map containing `:handler` containing callback functions: `:success`, `:error` and `:done`
|
- an opts map containing `:handler` containing callback functions: `:success`, `:error` and `:done`
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@
|
||||||
promise? (instance? clojure.lang.IPending chan)
|
promise? (instance? clojure.lang.IPending chan)
|
||||||
exception (when (and promise? error?)
|
exception (when (and promise? error?)
|
||||||
(ex-info ex-message ex-data))
|
(ex-info ex-message ex-data))
|
||||||
|
;; NOTE: if we need more fine-grained handlers, we will add
|
||||||
|
;; a :raw handler that will just get the bencode message's raw
|
||||||
|
;; data
|
||||||
{error-handler :error
|
{error-handler :error
|
||||||
done-handler :done
|
done-handler :done
|
||||||
success-handler :success} (when (map? chan)
|
success-handler :success} (when (map? chan)
|
||||||
|
|
@ -165,7 +168,7 @@
|
||||||
reply (read stdout)
|
reply (read stdout)
|
||||||
format (-> (get reply "format") bytes->string keyword)
|
format (-> (get reply "format") bytes->string keyword)
|
||||||
ops (some->> (get reply "ops") keys (map keyword) set)
|
ops (some->> (get reply "ops") keys (map keyword) set)
|
||||||
pod-id (get-maybe-string reply "pod-id")
|
;; pod-id (get-maybe-string reply "pod/id")
|
||||||
pod {:process p
|
pod {:process p
|
||||||
:pod-spec pod-spec
|
:pod-spec pod-spec
|
||||||
:stdin stdin
|
:stdin stdin
|
||||||
|
|
@ -178,8 +181,9 @@
|
||||||
:remove-ns remove-ns}
|
:remove-ns remove-ns}
|
||||||
_ (add-shutdown-hook! #(destroy pod))
|
_ (add-shutdown-hook! #(destroy pod))
|
||||||
pod-namespaces (get reply "namespaces")
|
pod-namespaces (get reply "namespaces")
|
||||||
pod-id (or pod-id (when-let [ns (first pod-namespaces)]
|
pod-id (or (when-let [ns (first pod-namespaces)]
|
||||||
(get-string ns "name")))
|
(get-string ns "name"))
|
||||||
|
(next-id))
|
||||||
pod (assoc pod :pod-id pod-id)
|
pod (assoc pod :pod-id pod-id)
|
||||||
vars-fn (fn [ns-name-str vars]
|
vars-fn (fn [ns-name-str vars]
|
||||||
(reduce
|
(reduce
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue