updated README

This commit is contained in:
Jude Payne 2023-05-04 09:25:49 +01:00
parent 7ed071f13b
commit d76f26f5f1
2 changed files with 32 additions and 2 deletions

View file

@ -376,11 +376,15 @@ nil
#### Metadata
##### From pod to pod client
1. Fixed Metadata on vars
Pods may attach metadata to functions and macros by sending data to the pod client
in a `"meta"` field as part of a `"var"` section. The metadata must be an appropriate
map, encoded as an EDN string. This is only applicable to vars in the pod and will be
ignored if the var refers to Client-side code, since metadata can already be defined
in those code blocks.
in those code blocks (see 'Dynamic Metadata' below to enable the encoding of metadata).
For example, a pod can define a function called `add`:
@ -392,6 +396,32 @@ For example, a pod can define a function called `add`:
"meta" "{:doc \"arithmetic addition of 2 arguments\" :arglists ([a b])}"}]}]}
```
2. Dynamic Metadata
Pods may send metadata on values returned to the client if metadata encoding is enabled
for the particular transport used by the pod.
For example, if your pod uses `transit+json` as its format, you can enable metadata
encoding by adding `:transform transit/write-meta` (or whatever transit is aliased to)
to the optional map passed to `transit\writer`. e.g.:
````clojure
(transit/writer baos :json {:transform transit/write-meta})
````
##### From pod client to pod
Currently sending metadata on arguments passed to a function is available only for the
`transit+json` format and must be explicitly enabled on a per var basis.
For example a pod can enable metadata to be read on arguments for the `round-trip` function:
````clojure
{:format :transit+json
:namespaces [{:name "pod.babashka.demo"
:vars [{"name" "round-trip" "read-metadata?" "true"}]}]}
````
#### Deferred namespace loading
When your pod exposes multiple namespaces that can be used independently from

View file

@ -142,7 +142,7 @@
name-sym (if vmeta
(with-meta name-sym vmeta)
name-sym)
meta-args? (get-maybe-boolean var "metadata?")]
meta-args? (get-maybe-boolean var "read-metadata?")]
(when meta-args?
(swap! vars-with-metadata-on-args update (:pod-id pod) conj sym))
[name-sym