Fork me on GitHub
#polylith
<
2024-03-24
>
Chris Lester05:03:14

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.

Patrix05:03:06

I remember encountering this kind of problem as well and solving it.. but I can't remember how I solved it 😅

Patrix05:03:03

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")

tengstrand06:03:10

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.

✔️ 1
Chris Lester06:03:10

I have that structure already, copied it from the polylith project.

Chris Lester06:03:28

Which is why it’s strange … other components resources load fine, just not these.

Chris Lester06:03:53

Oh, and the component is a config loader, nothing to do with pedestal beyond that.

tengstrand07:03:27

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

✔️ 1
furkan3ayraktar13:03:31

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.

✔️ 1
Chris Lester05:03:20

@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.

Chris Lester06:03:22

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).

🚀 1
1
furkan3ayraktar06:03:52

Great that it is solved! 🙌