Implement new load op which loads namespaces on demand
borkdude opened this issue · comments
See #14.
TODO:
- test for nested namespace: loaded ns1 needs loaded ns2. This had a deadlock bug which is now fixed.
Pods like bootleg have namespaces that are quite heavy on the client side code, which makes the describe message quite big and processing the client side code in sci takes a while. If a pod client does not use all these namespaces, it still pays the startup time for the unused namespaces.
To solve these issues, we will implement a new op called load
(named after clojure.core/load
). This operation is optional and will only be used if the pod provides this as part of the ops
in describe
, so it's not mandatory for all pods.
If a pod supports load
it will only describe the namespaces
's name
but will leave the vars
out of the describe message.
Upon receiving a load
message with {"path" "pod.bootleg.xml"}
the pod is going to reply with a message that provides {"vars" [ ... ] }
similar to what was previously provided in the describe message.
Note: pods will have to declare dependencies on other namespaces using a client side require expression "(require '[pod.bootleg.xml-utils])"
, so the pod will load these namespaces before processing the rest of the namespace:
{"vars"
[{"code" "
(require '[pod.bootleg.xml-utils] :as u)
(defmacro foobar [] (u/foo))"}]
}
Im not clear on how the initial describe
call declares that this pod supports a subsequent load
? Is an empty namespace {"vars" []}
and a lazy loaded namespace just empty hashmap {}
? What about something more descriptive, like {"lazy" true}
?
@retrogradeorbit The pod protocol (and similarly nREPL protocol) already provides for this. There will be a new entry in ops
. See docs here: https://github.com/babashka/babashka.pods#describe.