wip
This commit is contained in:
parent
bc28a705b6
commit
22be2b5842
3 changed files with 7 additions and 5 deletions
|
|
@ -235,14 +235,16 @@
|
||||||
|
|
||||||
(defn load-ns [pod namespace callback]
|
(defn load-ns [pod namespace callback]
|
||||||
(let [id (next-id)
|
(let [id (next-id)
|
||||||
|
prom (promise)
|
||||||
callback (fn [reply]
|
callback (fn [reply]
|
||||||
(let [[name-sym vars] (bencode->namespace pod reply)]
|
(let [[name-sym vars] (bencode->namespace pod reply)]
|
||||||
(callback {:name name-sym :vars vars})))]
|
(callback {:name name-sym :vars vars :done prom})))]
|
||||||
(swap! callbacks assoc id callback)
|
(swap! callbacks assoc id callback)
|
||||||
(write (:stdin pod)
|
(write (:stdin pod)
|
||||||
{"op" "load"
|
{"op" "load"
|
||||||
"path" (str namespace)
|
"path" (str namespace)
|
||||||
"id" id})))
|
"id" id})
|
||||||
|
@prom))
|
||||||
|
|
||||||
(defn invoke-public [pod-id fn-sym args opts]
|
(defn invoke-public [pod-id fn-sym args opts]
|
||||||
(let [pod (lookup-pod pod-id)]
|
(let [pod (lookup-pod pod-id)]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [babashka.pods.impl :as impl]
|
(:require [babashka.pods.impl :as impl]
|
||||||
[sci.core :as sci]))
|
[sci.core :as sci]))
|
||||||
|
|
||||||
(defn process-namespace [ctx {:keys [:name :vars]}]
|
(defn process-namespace [ctx {:keys [:name :vars :done]}]
|
||||||
(let [env (:env ctx)
|
(let [env (:env ctx)
|
||||||
ns-name name
|
ns-name name
|
||||||
sci-ns (sci/create-ns ns-name)]
|
sci-ns (sci/create-ns ns-name)]
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
(symbol (str ns-name) (str var-name)) var-value))
|
(symbol (str ns-name) (str var-name)) var-value))
|
||||||
(string? var-value)
|
(string? var-value)
|
||||||
(sci/eval-string* ctx var-value))))
|
(sci/eval-string* ctx var-value))))
|
||||||
#_(prn (get-in @env [:namespaces ns-name]))))
|
#_(prn (get-in @env [:namespaces ns-name])))
|
||||||
|
(when done (deliver done :ok)))
|
||||||
|
|
||||||
(def load-pod
|
(def load-pod
|
||||||
(with-meta
|
(with-meta
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@
|
||||||
|
|
||||||
(require '[pod.test-pod.loaded])
|
(require '[pod.test-pod.loaded])
|
||||||
|
|
||||||
(find-ns 'pod.test-pod.loaded) ;; nil, but this call makes the next call pass. huh?
|
|
||||||
(def loaded (pod.test-pod.loaded/loaded 1))
|
(def loaded (pod.test-pod.loaded/loaded 1))
|
||||||
|
|
||||||
(pods/unload-pod pod-id)
|
(pods/unload-pod pod-id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue