phoenixframework / phoenix

Peace of mind from prototype to production
https://www.phoenixframework.org
MIT License
21.4k stars 2.87k forks source link

Configuration of Swoosh in an Umbrella app #5453

Closed thojanssens closed 1 year ago

thojanssens commented 1 year ago

When scaffolding an Umbrella app, the following config is added for prod:

config :swoosh, :api_client, MyApp.Finch

However, as there are multiple apps and so, potentially multiple instances of Finch with different configurations, I cannot make sense and reason about this config setting.

Take the example of the Mailer, I can have one mailer per app, which makes sense in Umbrella:

config :foo_app, FooApp.Mailer, adapter: Swoosh.Adapters.Local

config :bar_app, BarApp.Mailer, adapter: Swoosh.Adapters.Local

Logically swoosh should take the Finch instance of the app that it's running in.

Gazler commented 1 year ago

I believe here swoosh only allows a single API client, so there would be no way to route different applications through different API clients. The API client is separate from the adapter, so it is totally possible to have one application sending via Mailgun and another via Sendgrid.

If you want to do this, it should be possible to write your own Swoosh.APIClient which can delegate to separate finch instances if required.