Fork me on GitHub
#polylith
<
2023-06-21
>
jeroenvandijk19:06:47

I did a small experiment running Polylith from Babashka 🙂 Not sure how correct it is, but it looks like something authentic https://clojurians.slack.com/archives/CLX41ASCS/p1687375787894849?thread_ts=1687355757.823539&amp;cid=CLX41ASCS

babashka 5
🔥 2
boolpath19:06:11

Nice! @U0GL2VCAJ might be interested

jeroenvandijk19:06:33

I’ll push what I have to a fork

heow19:06:26

nice! How fast does it run?!?

jeroenvandijk19:06:26

Sort of instant on the Polylith project. I just broke something, one sec for exact numbers

jeroenvandijk19:06:39

Ok instant was exagerated, but:

bb --config projects/poly-bb/bb.edn --debug -m polylith-bb.core info  3.48s user 0.38s system 138% cpu 2.784 total

jeroenvandijk19:06:54

On the same machine with clojure

clojure -M:poly info  41.82s user 1.82s system 338% cpu 12.890 total

tengstrand04:06:44

Interesting. Nice work!

😃 2
jeroenvandijk07:06:46

You can try it out your self by cloning my repo and running bbin install ./. --as poly-bb --local/root projects/poly-bb. I have asked for https://clojurians.slack.com/archives/C0400TZENE7/p1687418226535869 to make it more fluent

jeroenvandijk07:06:56

@U0GL2VCAJ I made some small changes and it is a second faster now. info command is less than 2 seconds vs 13 seconds with clojure. It can be optimized a lot more if necessary by lazy loading namespaces

jeroenvandijk07:06:32

This might also be interesting for Windows users (if there are any), as I’m guessing Polylith doesn’t run there because of the clojure tool dependency

jeroenvandijk07:06:35

Before I disappoint people, I only tested the tool with info . Now I’m trying it a bit more on an actual project and I see that the test command is more connected to the jvm itself so this one doesn’t work yet

jeroenvandijk07:06:30

So far it seems only the test and shell comand are not supported

jeroenvandijk19:06:08

My idea is that it would be easier to add custom adhoc commands without bloating the polylith process. Also startup time of course for one time tasks

Drew Verlee21:06:07

My team had some questions about Polylith, which i would like to share alongside my answers in hopes of getting some feedback. ✍️ 1. Could compare and contrast managing inter-component dependencies between a Polylith architecture and stuartsierra/component, especially management of the situation where some “LEGO brick” needs to be instantiated before another can start (in our system one example might be that the db needs to be “up” before the API service components start) A Polylith component is made of an interface and an implementation, the implementation could be backed by a stuartsierra component. The interface would allow for the functions that act upon the component to be swapped at build time. Here is a https://github.com/seancorfield/usermanager-example/blob//components/database/src/usermanager/database/interface.clj#L23 to an interface that calls out to a function that uses a start seirra component. Put another way, Polylith deals with dependencies of code bundles and would leave stuart sierra component to handle the stateful dependency man agent of the runtime system. 2. Can we get an example of integrating a Polylith project into an AWS-flavored CI/CD pipeline? Polylith uses the existing clojure tools and deps.edn tooling to manage build time dependencies, so building a jar wouldn't change, as you can see in this http://1.%20please%20compare%20and%20contrast%20managing%20inter-component%20dependencies%20between%20a%20Polylith%20architecture%20and%20stuartsierra/component%20especially%20management%20of%20the%20situation%20where%20some%20“LEGO%20brick”%20needs%20to%20be%20instantiated%20before%20another%20can%20start%20(in%20our%20system%20one%20example%20might%20be%20that%20the%20db%20needs%20to%20be%20“up”%20before%20the%20API%20service%20components%20start)%20%20A%20Polylith%20[component](https://polylith.gitbook.io/polylith/architecture/2.3.-component)%20is%20made%20of%20a%20interface%20and%20an%20implementation,%20the%20implementation%20could%20be%20backed%20by%20a%20stuartsierra%20component.%20The%20interface%20would%20allow%20for%20the%20functions%20that%20act%20upon%20the%20component%20to%20be%20swapped%20at%20build%20time.%20Here%20is%20a%20[link](https://github.com/seancorfield/usermanager-example/blob//components/database/src/usermanager/database/interface.clj#L23)%20to%20interface%20which%20calls%20out%20to%20a%20function%20which%20uses%20a%20component.%20%20Put%20another%20way,%20Polylith%20deals%20with%20dependencies%20of%20code%20bundles,%20and%20would%20leave%20stuart%20sierra%20component%20to%20handle%20the%20tasteful%20dependency%20man%20agent%20of%20the%20runtime%20system.%20%20%202.%20Can%20we%20get%20an%20example%20of%20integrating%20a%20Polylith%20project%20into%20an%20AWS-flavored%20CI/CD%20pipeline?%20%20Polylith%20uses%20the%20existing%20clojure%20tools%20and%20deps.edn%20tooling%20to%20manage%20build%20time%20dependencies,%20so%20building%20a%20jar%20wouldn't%20change,%20as%20you%20can%20see%20in%20this%20[link](https://github.com/seancorfield/usermanager-example/blob//README.md?plain=1#L100)%20where%20the%20uber%20jar%20is%20built%20using%20the%20same%20command%20as%20we%20do%20`(clojure%20-T:build%20uber)`%20with%20the%20notable%20difference%20that%20the%20deps.edn%20file,%20makes%20extensive%20use%20of%20clojure%20tools%20local/root%20functionality%20to%20point%20to%20nested%20deps%20(as%20opposed%20to%20the%20typical%20top%20level%20one)%20inside%20the%20mono%20repo,%20as%20you%20can%20see%20[here](https://github.com/seancorfield/usermanager-example/blob//projects/usermanager/deps.edn#L3)%20there%20internal%20deps%20allow%20polylith%20to%20more%20easily%20perform%20crud%20operations%20on%20your%20project.%20%20Polylith,%20as%20a%20CLI%20could%20also%20change%20pre-build%20functionality%20such%20as%20how%20the%20command%20is%20called%20`clojure%20-M:poly%20test%20:all%20:dev`%20as%20well%20as%20how%20long%20the%20test%20take%20to%20run%20because%20only%20the%20polylith%20components%20that%20are%20effected%20by%20the%20change%20that%20triggered%20the%20build%20will%20be%20run.%20%20%20%203.%20How%20much%20of%20the%20leverage%20Polylith%20provides%20is%20focused%20on%20multi-team,%20multi-service%20environments%20and%20how%20much%20does%20it%20benefitting%20a%20one-team%20(maybe%20two-team)%20shop%20that%20ships%20a%20monolith%20in%20a%20Docker%20container%20with%20configuration%20for%20feature%20selection,%20as%20we%20do?%20%20Given%20what%20Polylith%20is,%20functionality%20over%20the%20project(s)%20to%20provide%20crud%20operations,%20for%20example,%20analysis%20of%20dependencies%20across%20Polylith%20components.%20That%20analysis%20would%20likely%20become%20more%20valuable%20as%20the%20project%20and%20team%20size%20grew.%20%204.%20Are%20their%20any%20projects%20that%20have%20migrated%20from%20stuartsierra/component%20to%20Polylith%20piecemeal%20or%20at%20least%20without%20a%20stop-the-world%20refactor%20to%20migrate%20the%20entire%20codebase,%20that%20would%20be%20very%20interesting%20to%20know%20about.%20Even%20pointers%20to%20successful%20migrations%20that%20did%20require%20a%20stop-refactor-start%20process%20would%20be%20good%20to%20review%20but%20the%20ideal%20case%20would%20be%20one%20that%20demonstrated%20the%20ability%20to%20migrate%20one%20component%20at%20a%20time.%20%20To%20be%20clear,%20there%20is%20no%20migration%20from%20stuartsierra%20components%20to%20Polylith,%20rather%20it%20would%20be%20an%20incorporation%20of%20stuartsierra%20components%20within%20a%20Polylith%20system.%20You%20can%20see%20Sean's%20example%20project%20that%20does%20that%20[here](https://github.com/seancorfield/usermanager-example/tree/polylith)%20in%20two%20steps.%20There%20is%20also%20the%20Transition%20guide%20which%20you%20can%20check%20out%20[here](https://polylith.gitbook.io/polylith/conclusion/should-you-convert-your-system). where the uber jar is built using the same command as we do (clojure -T:build uber) with the notable difference that the deps.edn file, makes extensive use of clojure tools local/root functionality to point to nested deps (as opposed to the typical top-level one) inside the mono repo, as you can see https://github.com/seancorfield/usermanager-example/blob//projects/usermanager/deps.edn#L3 their internal deps allow polylith to more easily perform crud operations on your project. Polylith, as a CLI could also change pre-build functionality such as how the command is called clojure -M:poly test :all :dev as well as how long the test take to run because only the polylith components that are effected by the change that triggered the build will be run. 3. How much of the leverage Polylith provides is focused on multi-team, multi-service environments and how much does it benefitting a one-team (maybe two-team) shop that ships a monolith in a Docker container with configuration for feature selection, as we do? Given what Polylith is, functionality over the project(s) to provide crud operations, for example, analysis of dependencies across Polylith components. That analysis would likely become more valuable as the project and team size grew. 4. Are there any projects that have migrated from stuartsierra/component to Polylith piecemeal or at least without a stop-the-world refactor to migrate the entire codebase, that would be very interesting to know about. Even pointers to successful migrations that did require a stop-refactor-start process would be good to review but the ideal case would be one that demonstrated the ability to migrate one component at a time. To be clear, you will keep your stuartsierra components when migrating to Polylith , rather it would be an incorporation of the prexisting stuartsierra components within a Polylith system. You can see Sean's example project that does that https://github.com/seancorfield/usermanager-example/tree/polylith in two steps. There is also the Transition guide which you can check out https://polylith.gitbook.io/polylith/conclusion/should-you-convert-your-systemher.

❤️ 2
👍 2
seancorfield22:06:08

1. Yes, Sierra's Component library deals with a completely orthogonal concern to the "components" (bricks) in Polylith. 2. Kind of a non-sequitur question. Polylith uses regular Clojure CLI tooling. Note: clojure -M:poly test would only test things that changed -- with :all :dev you are forcing everything to be tested, including the development project, which is not normal (although it would be possible if you really wanted to force test your entire world). 3. If a team only ships one artifact from a monorepo, it kind of isn't a "monorepo" 🙂 But, yes, the insight provided by the tooling and the ability to run a dev REPL with local/lightweight implementations swapped in for heavyweight/external services should still provide value. 4. Again, orthogonal, but our migration at work was from an ad hoc monorepo that uses Component to a Polylith-structured monorepo that still uses Component in exactly the same way.

Drew Verlee22:06:37

Thanks a ton for the reply. Ill share what i found and let them stew on the ideas for a bit.

tengstrand04:06:08

The links are broken (the branch name is missing, you have // instead of /polylith/ in the links) @U0DJ4T5U1.

seancorfield04:06:59

I hadn't checked the links... I think most of the ones into my usermanager repo are correct (but not all). The first link seems to be <http://1>.%20please%20compare%20and%20contrast%20managing%20inter-component%20dependencies%20between%20a%20polylith%20architecture%20and%20stuartsierra/component%20especially%20management%20of%20the%20situation%20where%20some%20%E2%80%9CLEGO%20brick%E2%80%9D%20needs%20to%20be%20instantiated%20before%20another%20can%20start%20(in%20our%20system%20one%20example%20might%20be%20that%20the%20db%20needs%20to%20be%20%E2%80%9Cup%E2%80%9D%20before%20the%20API%20service%20components%20start)%20%20A%20Polylith%20component. 🙂

seancorfield04:06:22

(I'm guessing you asked ChatGPT about this?)

Drew Verlee04:06:44

Lol. Well, I'll fix the links for my co-workers. Ty for noticing.

Drew Verlee04:06:08

I didn't ask chatgpt, i used an emacs fn to copy the location in git. Looks like something went wrong.

Drew Verlee04:06:54

Or when i copied it to slack, which i wish had a markdown mode...

Thomas Moerman08:06:30

1, 4: I don't see polylith to be a competitor of [component|donut-system|integrant], rather as complementary elements of a modular architecture. In our project, the polylith components expose both functions (called directly from other components), as well as data-structures or stateful objects*, the latter are used by a base, that uses a component-like library (donut in our case), to "assemble" the system. * components typically expose: • routes • interceptors (or factory functions thereof, when they need "injected" things) • transaction functions (xtdb) • pathom resolvers • entity schemas (malli) • start/stop functions for stateful things (e.g. xtdb node) These are used by a growing donut system configuration map that performs the "dependency injection" / component-esque steps at system startup. I could perhaps formalize a "component-interface" this into some kind of protocol or schema, haven't bothered yet. I regard polylith as an approach to structure code "at rest", to give code a place in the overall code base, and to offer a perspective on dependencies and coupling. The dynamic "system assembly" part (at runtime) is handled by the component system. Is a component-system necessary? Probably not, you could also use mount, but i personally prefer a component-like approach.

pavlosmelissinos09:06:25

> Or when i copied it to slack, which i wish had a markdown mode... off topic (sorry) but since you asked: Slack actually has a markdown(ish) mode, you just need to enable this setting. You lose the rich text formatter but imho it's worth it.

👍 2