Hi all, is there any documentation on how duct.profile keys work? e.g. :duct.profile/local
. Can I create more profiles and can I switch between profiles in the repl?
There is not so much documentation available, but you can read the code.
(defn -main [& args]
(let [keys (or (duct/parse-keys args) [:duct/daemon])
profiles [:duct.profile/prod]]
(-> (duct/resource "film_ratings/config.edn")
(duct/read-config)
(duct/exec-config profiles keys)))) ; Heres the entry point for production profile
If you look into dev/src/dev.clj
(def profiles
[:duct.profile/dev :duct.profile/local])
...
(integrant.repl/set-prep! #(duct/prep-config (read-config) profiles)) ; here we change the prep fn and use profiles defined above
When you call (go)
the code will call (prep)
and then (init)
https://github.com/weavejester/integrant-repl/blob/89a9552fd3623976b83318a5f8f903f1ebeda2f7/src/integrant/repl.clj#L53
(prep)
will change config https://github.com/weavejester/integrant-repl/blob/89a9552fd3623976b83318a5f8f903f1ebeda2f7/src/integrant/repl.clj#L14
And init will start the system
You definitely can create more profiles.
Just remember to derive from :duct/profile
And add :duct.profile/yourown #duct/include "yourown"
in config.edn
About switching profiles I think you can execute (def profiles [:duct.profile/dev :duct.profile/yourown])
inside the dev
ns in the repl. Although I’ve never did that and don’t know how it might affect the system.
Thanks! that's very helpful 🙂 I'll play around with it at the repl