I'm in the process of breaking our larger/monolithic app into separate repos so we can bring the pieces in as dependencies on other apps.
However, a key problem we are running into is ultimately around the database models.
We're working on a separate thing around most of that, but at the heart the problem comes in that we are one level too far removed, so a LOT of warnings appear during compile, even though they aren't relevant at runtime — notably stuff like below on the dependency compile.
I've looked at how oban handles it, and they setup an inefficient
layer of indirection (obfuscation) to hide the warning.
The resulting code with a warning includes the atom for the repo module, and everything works fine. The warnings are legitimate in the myopic context of compiling ONLY the dependency, but are not correct when considering the complete application.
I could perhaps add something like `[xref: [exclude: [Core.Repo]]]` to the dependent library's project data/mix.exs, and that might be fine for a closed-world where we don't share the library. But we are considering opening the library to the public, so this isn't a valid solution.I feel like this same problem is resolved with umbrella
applications.
Which makes me wonder, perhaps there could be a way to treat an external dependency like a member of the umbrella, and inject stuff like the xref in at the deps() array level, rather than from within that project?
While I'm not a fan of premature optimization, but I do care
about keeping in mind the things that will have a potential of
high-frequency calls, and avoiding doing anything obviously
dangerous with those, especially over just a vanity thing.
In this case the warning isn't a real problem, it's just something the compiler thinks could be a problem.
Is there some other way to do this short of putting in a less efficient abstraction layer just to make it so the compiler can't detect what's really happening?
I'm just throwing mud on the wall now but something like:
Ultimately, the problem I have with all of the hereto offered solutions is that they effectively boil down to "obfuscate your code enough that the compiler won't throw a warning."
But that's seriously misaligned in my opinion.
The goal of coding should be (a) creating simple but efficient code to execute in production that is (b) readable and maintainable. These obfuscation/vanity recommendations violate both of these points.
I don't know what the right solution is. I just feel like there should be something better than what's there now.
-Brandon
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/4b127f8b-ddcb-b25e-0e7c-12af3af68252%40cold.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LPM3tniuop5VivZZTEoFCMZuM-vimv1U9yF4tvDy2-NA%40mail.gmail.com.
On 3/10/23 3:33 PM, Austin Ziegler wrote:
- The warning that I think is being discussed is a compile warning for the library dependency, not for the hosting application, which matches what I have seen.
This.
I'm working on creating a focused way of reproducing it, but need some time to get it all dialed in.
Essentially though, you are right.
What we are working on is a way to put Ecto models into a library dependency that can be brought into other applications. But for this to work, we have to abstract the definition of Ecto.Repo and defer it to runtime. However, because dependencies are pre-compiled, you then get these warnings.
This is a use case that's very compelling, and yet it goes against how things work right now with the way dependencies are, but that doesn't remove the value of having something like this.
oban is a great example.
-Brandon
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/194c5d9c-6ba3-6599-0436-caae01bec86c%40cold.org.
That's where I was suggesting something on the deps line that could be inserted into the dependency's spec in mix.exs, like:
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/lf3c11ws.8e05e338-daf8-44e1-aca4-5e4d26f470d0%40we.are.superhuman.com.
This does actually strike a chord for me and I'm realizing this is likely a related question or perhaps the same question in another form. Is there some way to define a module that a dependency can use at compile time or at runtime without these warnings? Like a module that you want compiled before a specific dependency/dependencies?
On Fri, Mar 10, 2023 at 9:11 PM, Brandon Gillespie <bra...@cold.org> wrote:
On 3/10/23 3:33 PM, Austin Ziegler wrote:
- The warning that I think is being discussed is a compile warning for the library dependency, not for the hosting application, which matches what I have seen.
This.
I'm working on creating a focused way of reproducing it, but need some time to get it all dialed in.
Essentially though, you are right.
What we are working on is a way to put Ecto models into a library dependency that can be brought into other applications. But for this to work, we have to abstract the definition of Ecto.Repo and defer it to runtime. However, because dependencies are pre-compiled, you then get these warnings.
This is a use case that's very compelling, and yet it goes against how things work right now with the way dependencies are, but that doesn't remove the value of having something like this.
oban is a great example.
-Brandon
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/194c5d9c-6ba3-6599-0436-caae01bec86c%40cold.org.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/lf3c11ws.8e05e338-daf8-44e1-aca4-5e4d26f470d0%40we.are.superhuman.com.