Can't use this library if using `fun_with_flags` with `runtime: false`
whatyouhide opened this issue · comments
We use fun_with_flags
as suggested in its README, that is:
runtime: false
- We start
FunWithFlags.Supervisor
manually in our application's supervisor
If I try to use fun_with_flags_ui
, this becomes problematic. fun_with_flags_ui
lists fun_with_flags
as a dependency without runtime: false
. This means that the fun_with_flags
application gets started anyways.
I think what we'd want to do in fun_with_flags_ui
is:
- List
fun_with_flags
as dependency withruntime: false
- In
fun_with_flags_ui
'sApplication
module, we manually startFunWithFlags.Supervisor
Thoughts?
@tompave to be clear: ideally, I don't think fun_with_flags
should have an application callback module at all. I think we should start both manually. But that would be a breaking change for fun_with_flags
(albeit one that I would definitely support!).
Hi, I'm sorry that this stuff still a bit clunky.
On removing the applications callback: yes, that's definitely how I'd do it now. It's something for v2.0, though.
In the meantime, would this paragraph from that section of the FWF readme help?
One final note on this topic is that if you're also using
FunWithFlags.UI
(...), then that will need to be configured as well. The reason is that:fun_with_flags
is a dependency of:fun_with_flags_ui
, so including the latter as a dependency will cause the former to be auto-started despite the configuration described above. To avoid this, the same configuration should be used for the:fun_with_flags_ui
dependency, regardless of the approach used (Option A:runtime: false
,app: false
; or Option B:included_applications
).
Doing that worked for me when I tested different setups, but maybe your config is different (or something has changed in Elixir).
@tompave for some reason yesterday adding runtime: false
to :fun_with_flags_ui
didn't work, but it does today. I was under the impression that even with :fun_with_flags_ui, runtime: false
then dependencies of fun_with_flags_ui
, which include fun_with_flags
, would be started.
In any case... Is a v2.0 on the horizon? I'd be more than happy to help out with everything required to make that happen. This is such a foundational library (and such a well-made one!) in the Elixir ecosystem that I'd love to bring it up to speed with best practices 🙃
but it does today
So you're unblocked? That's great!
For v2.0, my main three goals are:
- Config overhaul. Stop using the
config.exs
file, and rather do something like what Ecto does. The host application should define its own module (like an Ecto repo!), and then calluse FunWithFlags.SomeDescriptiveName
. And most config should be provided with aninit
callback in the custom module. - Start behaviour. It should never start automatically.
- Stop relying on atoms. Use binaries wherever possible. Relying on atoms that way make some things harder, especially when handling user input in the UI package.
I started working on 1
some time ago. I need to resume that.
Closing this as it was resolved.