In the Elixir umbrella app, where should the backend app be added to register as a dependency?

I have an Elixir umbrella. Applications under the umbrella use Logger . I want to add backend ( logger_logstash_backend ) for the application :logger . Therefore, I need to add this as a dependency in the deps function in the mix file.

In the most remote umbrella application mixing file, the deps function documentation says:

The dependencies listed here are available only for this project and cannot be accessed from applications inside the application folder

This means that I have to add a backend module as a dependency for each of the applications under the umbrella. However, this raises several problems:

  • It is more difficult to display individual applications as separate libraries later.

  • Individual applications under an umbrella are actually independent of the user module :logger . They are ok with the default backend :console . But I want to have an extra backend only for the prod environment. Thus, it is more connected with cross-applications, in which I have to add a dependency to each application every time.

Do you know any better strategy? What is it?

+7
erlang elixir phoenix-framework
source share
2 answers

Just specify the dependency in your external applications. You can then configure each application to use a new logging backend.

0
source share

Each application must have its own dependencies and configuration.

The problems you talked about:

  • It is more difficult to move individual applications as separate libraries later.

If you have configurations within each application, it actually makes it easier to port individual applications from an umbrella application. As mentioned in Elixir manuals , you just need to move the application from the apps/ directory.

  1. Individual applications under an umbrella are virtually independent of the user: module backend. They are fine with the standard: console backend. But I want to have an extra backend only for the prod environment. Thus, this is more related to cross-application, where I am forced to add a dependency for each application separately.

If a custom backend is required only in the production environment, applications can add this configuration only to the config/prod.exs and use it only in the prod environment.

0
source share

All Articles