This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-24
Channels
- # beginners (17)
- # calva (29)
- # clojure-europe (37)
- # clojure-germany (11)
- # clojure-norway (24)
- # datalevin (11)
- # datascript (2)
- # fulcro (13)
- # hoplon (8)
- # humbleui (7)
- # hyperfiddle (6)
- # keechma (2)
- # malli (5)
- # nextjournal (4)
- # off-topic (10)
- # polylith (12)
- # releases (1)
- # shadow-cljs (13)
- # squint (106)
- # yamlscript (1)
Is there something I need to do differently to load resources where I have multiple implementations of a component interface? I.e., config-servicea and config-serviceb .. which are the local roots for a config-pedestal component. (io/resource "config-pedestal/config.edn") returns nil .. even though resources/config-pedestal exists (as does the config.edn file). I can handle this by moving those files out of the jar .. but I'd rather not do that work just as a workaround.
I remember encountering this kind of problem as well and solving it.. but I can't remember how I solved it 😅
I can't find anything special in my code related to that.. just using (io/resource "component-name/templates")
(e.g. for a selmer templates path) or similarly for my a json file containing test data (io/resource "component/payload.json")
I haven't used Pedestal, but will try to answer the question anyway. Let's say the interface of config-servicea
and config-serviceb
is config-service
then put the resource file(s) in resources/config-service
(a directory with the interface name), e.g. components/config-servicea/resources/config-service
and components/config-serviceb/resources/config-service
. This will let you switch implementations.
I have that structure already, copied it from the polylith project.
Which is why it’s strange … other components resources load fine, just not these.
Oh, and the component is a config loader, nothing to do with pedestal beyond that.
If you want, you can export your workspace and send it to me, and I will have a look (with e.g. ws out:chris.edn
). What version of the poly
tool do you use? @US893PCLF
It might be obvious but just wanted to mention that “resources” directory should be listed under the :paths
key of the deps.edn files of both components. Also, the aliases you use for switching implementations while starting a REPL should include either one of the components.
@U1G0HH87L the version is: 0.2.18 (2023-12-19) @U2BDZ9JG3 .. that is in the deps.edn, I only have one of these components currently and haven't updated the REPL alias for this yet as I've been sidetracked on this io/resource problem but is a good reminder to do that.
Thx @U2BDZ9JG3 .. your comment reminded me to check the switches which led to restarting it. So it was the simplest possible problem .. I'd forgotten to reload the repl after renaming the dirs to the interface name (vs the impl name).
Great that it is solved! 🙌