Get rid of :needs-ctx
This commit is contained in:
parent
a0418d6622
commit
e71ae00d03
2 changed files with 56 additions and 57 deletions
|
|
@ -19,9 +19,7 @@
|
||||||
(string? var-value)
|
(string? var-value)
|
||||||
(sci/eval-string* ctx var-value))))))
|
(sci/eval-string* ctx var-value))))))
|
||||||
|
|
||||||
(def load-pod
|
(defn load-pod
|
||||||
(with-meta
|
|
||||||
(fn
|
|
||||||
([ctx pod-spec] (load-pod ctx pod-spec nil))
|
([ctx pod-spec] (load-pod ctx pod-spec nil))
|
||||||
([ctx pod-spec opts]
|
([ctx pod-spec opts]
|
||||||
(let [env (:env ctx)
|
(let [env (:env ctx)
|
||||||
|
|
@ -68,7 +66,6 @@
|
||||||
(process-namespace ctx {:name ns-name :vars vars}))
|
(process-namespace ctx {:name ns-name :vars vars}))
|
||||||
(sci/future (impl/processor pod))
|
(sci/future (impl/processor pod))
|
||||||
{:pod/id (:pod-id pod)})))
|
{:pod/id (:pod-id pod)})))
|
||||||
{:sci.impl/op :needs-ctx}))
|
|
||||||
|
|
||||||
(defn unload-pod
|
(defn unload-pod
|
||||||
([pod-id] (unload-pod pod-id {}))
|
([pod-id] (unload-pod pod-id {}))
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,15 @@
|
||||||
(deftest sci-test
|
(deftest sci-test
|
||||||
(let [out (java.io.StringWriter.)
|
(let [out (java.io.StringWriter.)
|
||||||
err (java.io.StringWriter.)
|
err (java.io.StringWriter.)
|
||||||
ret (sci/binding [sci/out out
|
ctx-ref (volatile! nil)
|
||||||
sci/err err]
|
ctx (sci/init {:namespaces {'babashka.pods
|
||||||
(sci/eval-string
|
{'load-pod (fn [& args]
|
||||||
test-program
|
(apply pods/load-pod @ctx-ref args))
|
||||||
{:namespaces {'babashka.pods
|
|
||||||
{'load-pod pods/load-pod
|
|
||||||
'invoke pods/invoke
|
'invoke pods/invoke
|
||||||
'unload-pod pods/unload-pod}}
|
'unload-pod pods/unload-pod}}
|
||||||
:classes {'System System}}))]
|
:classes {'System System}})
|
||||||
|
_ (vreset! ctx-ref ctx)
|
||||||
|
ret (sci/binding [sci/out out
|
||||||
|
sci/err err]
|
||||||
|
(sci/eval-string* ctx test-program))]
|
||||||
(assertions out err ret)))
|
(assertions out err ret)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue