Fork me on GitHub
#polylith
<
2023-09-10
>
jasonjckn08:09:51

Should bases reference components they use in :deps?

furkan3ayraktar08:09:49

No, bases and components do not add each other as dependencies. They are added to the projects’ deps.edn.

👍 2
tengstrand08:09:02

Bases are the exception, they are allowed to access other bases, which you ned to be able to if you have more than one base in a project. But most of the time, one base is enough per project.

furkan3ayraktar08:09:44

Yes, but you do not specify them in the deps.edn as dependencies. They are added to the projects’ deps.edn.

tengstrand08:09:56

Yes, that's true.

furkan3ayraktar08:09:33

The question was about if bases should reference components (or bases) in their deps.edn. The answer to that is no.

tengstrand08:09:56

You are right!

🙌 2
furkan3ayraktar08:09:30

Just wanted to be clear 😂

💯 2
p14n12:09:34

Why is this exactly? I'd naturally put something infrastructurey (like a shared http routing component) in the bases that need it. Adding to a project feels like a leaky abstraction

tengstrand14:09:52

The base code refers to the component interface namespace, but which concrete component to use, that's a decision that is taken by the project.

jasonjckn18:09:52

it’s like how you would refer to library slf4j-api and not logback-classic or log4j2 , but in this case there’s no api jar , just impl jars

jasonjckn18:09:49

this really makes me wonder how (1) if it’s possible to define compile/link time interfaces analogous to slf4j-api and (2) other kinds of ‘link time’ abstractions

jasonjckn18:09:16

but i don’t have any concrete ideas yet how to approach that

jasonjckn18:09:12

for example if you wrote the interface file once instead of just once per implementing component and found a way to link them up , (autogenerate function bodies)

jasonjckn08:09:16

Let's say you were creating an component interface to ring-handler, and you had two implementations, one that's dev-time-only, it does a reloading requires each time you handle an HTTP request, and another that's production-grade. That's two different components right? that's the intention of polylith?

furkan3ayraktar08:09:29

Yes, it’s one of the concepts in Polylith. Each component has an interface and several components can implement the same interface. These components can then be included in different projects; e.g. one in development project, the other in the production.

jasonjckn08:09:58

cool, i like this idea, it's like zero cost abstraction, linker time

polylith 2
furkan3ayraktar08:09:37

There is a detailed explanation of this concept https://polylith.gitbook.io/poly/workflow/profile.

👍 2
jasonjckn08:09:42

thanks

🙌 2
seancorfield20:09:55

@U0J3J79FE I've blogged about swappable component implementations like this in my monorepo series on http://corfield.org -- e.g., our http-client interface is mostly implemented via an http-client-hato component, but we also have an httpkit-backed implementation for our legacy app that has to still run on JDK 8.

🙌 2