Giter VIP home page Giter VIP logo

Comments (7)

princemaple avatar princemaple commented on June 26, 2024 1

Thanks for your input @xadhoom !

from swoosh.

stevedomin avatar stevedomin commented on June 26, 2024

Hi @geofflane, sorry for the slow reply on this one.

I'm not really a fan of we deal with configuration at the moment, I'm going to rethink this in the next few days and I'll make sure we support conform.

If you have any ideas, please feel free to share.

from swoosh.

geofflane avatar geofflane commented on June 26, 2024

@stevedomin I don't have a lot of ideas necessarily. I'm not a huge fan of Mix.Config because it generates a static config at compile time and each individual library has to support things like :system if they want to have dynamic runtime properties. And each library has to be written so that is supports a model like Conform. That's a significant limitation of the Mix.Config design IMHO. I think the best I can come up with is to ensure that compile-time macros are not the thing that reads the configuration (no storing values in module attributes in the macto). Rather the configuration needs to be read when the application is running which allows a tool like Conform to interject itself and set the configuration up properly.

The only other idea I have, and I haven't tried this anywhere, is that it might be best if libraries with configuration had their own Agent (or GenServer or something) that was responsible for reading the configuration it needed when it started and then the code that needed the config could just ask for it from the Agent. Agents make sense to me because the library depends on global state already through a module attribute, and Agent is just an abstraction around state.

from swoosh.

xadhoom avatar xadhoom commented on June 26, 2024

I'm also interested in this topic, right now the only way is to pass env vars on startup which is far from being optimal.

from swoosh.

princemaple avatar princemaple commented on June 26, 2024

@xadhoom what do you think is the optimal way?

from swoosh.

xadhoom avatar xadhoom commented on June 26, 2024

Well,

I see basically 2 use cases (in addition to current "static" mix way):

  1. release mode, where the setup is read from a sys.config (which is generated by tools like conform)

  2. dynamic mode, where I want to choose the adapter/config each time I send an email (think about it as a "multihomed" setup where each user wants to deliver his emails in a different way

The first one can may solved with a wrapping module that basically calls Application.get_env without the burden of a separate process, this will be called by the macro-defined functions everytime without relying into a compiled in config. I don't think is more expensive than calling a process (but I have no data about that and it may be interesting to investigate on systems that do tons of deliveries)

The second one is almost there, since (if I'm not mistaken) swoosh already permits passing a config to the deliver fun, but does not allow passing an adapter. Basically we need a deliver/3 where also adapter is passed (or a deliver/2 where 2nd argument is a tuple {adapter, config}). Where to store that config is basically delegated to the user of the library.

At a first glance, both ways may be added to current code without breaking the compatibility.

jm2c

from swoosh.

xadhoom avatar xadhoom commented on June 26, 2024

obviously both modes are usable at same time, is just a matter of which deliver fun the user calls (so the env config will be used unless overridden by calling deliver/3)

from swoosh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.