Code Monkey home page Code Monkey logo

Comments (11)

weavejester avatar weavejester commented on August 23, 2024

With Environ I prefer to distinguish between the process environment, which is static, and the program's configuration, which may change. Conflating the two leads to inadvertent complexity.

For REPL development it's often more useful to work with the configuration directly. For example, in user.clj you might have:

(def user-config
  {:port 3000})

(def user-system
  (new-system user-config))

(defn start []
  (component/start user-system))

While your -main function might be defined:

(def env-config
  {:port (Integer. (:port env))})

(def main-system
  (new-system env-config))

(defn -main [& args]
  (component/start main-system))

The -main function derives its configuration from the environment, but the configuration is distinct from the environment.

from environ.

mbriggs avatar mbriggs commented on August 23, 2024

Thats a very good point :) I still think there is room for developer specific configuration, but maybe just a read on a separate file would be better for that.

from environ.

weavejester avatar weavejester commented on August 23, 2024

Why not define the developer configuration in a local user.clj?

from environ.

mbriggs avatar mbriggs commented on August 23, 2024

been checking in project user.clj. is that a bad idea?

from environ.

weavejester avatar weavejester commented on August 23, 2024

Ah, you mean a local configuration, out of version control. Perhaps a local.clj as well (excluded from the VCS), to complement user.clj? That would allow devs to add in their own alterations to the dev environment, as well as setting up local configurations.

from environ.

mbriggs avatar mbriggs commented on August 23, 2024

yeah, that makes loads of sense :)

from environ.

PetrGlad avatar PetrGlad commented on August 23, 2024

eviron still reads ".lein-env". Why cannot I do the same and load additional data from my own configuration file (I think of updating System/getProperties from additional file) ?
Maybe dispense with environ.core/env var and make it a function? If anyone cares about efficiency it's possible to defonce resulting value it in user code or use let binding.

from environ.

weavejester avatar weavejester commented on August 23, 2024

Environ isn't a library for reading configuration files; it's a tool for accessing the environment the process has started in. The .lein-env file is just a mechanism to allow the environment to be set from Leiningen.

from environ.

PetrGlad avatar PetrGlad commented on August 23, 2024

Of course it's not for reading files. I am happy to read that file and update System/getProperties in my code. But if I do that it won't affect env value because it is already initialized. If env is a function then I can construct and update it's resulting value however I need.
Having env value defonced forces me to gather additional external configs elsewhere what kind of defeats the purpose of unifying them with this library.

from environ.

mbriggs avatar mbriggs commented on August 23, 2024

The purpose of the lib is to handle environment configuration which may be set at several levels. After this PR i realized what i really wanted was (merge env (read-str (slurp "./config.clj"))), which isnt what environ is trying to tackle.

from environ.

weavejester avatar weavejester commented on August 23, 2024

Having env value defonced forces me to gather additional external configs elsewhere what kind of defeats the purpose of unifying them with this library.

That's not the purpose of this library. This library is designed to provide access to the process environment, it's not a library for reading configuration.

The .lein-env file is just an implementation detail that may disappear in future, if a better solution for getting information from active project map presents itself.

from environ.

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.