Reputation: 386
I have a Clojure application which process some data in our company. So I want to obtain possibility of its customization throw .myapp.clj
file or something like this.
It must be a simple script in clojure in which user can define own data processing principle. Also he must has possibility for tunning http back end and others application parts.
So, what is the best way to implement this fiche?
Upvotes: 0
Views: 81
Reputation: 91557
A couple ways come to mind with varying levels of sophistication. The simplest is to just have each user define a ~/.myall.clj
in their home directory and then the start of the program would include a line:
(def per-user-config (load-file "~/.myall.clj"))
load-file
reads a file and returns the last form read in the file. This allows you to compose config files nicely. For instance you can make a company wide template that has symbols for things like user-name
and then load it from a per-user config file that defines user-name and then calls load-file
on the template
config-template.clj:
{:app-name "foo"
:user-url (str "http://server.company:8080/users/" user-name)
:foo "bar"}
joes-config.clj:
(def user-name "joe")
(load-file "resources/global-config.clj")
this allows you to distribute most of the config through git while still allowing users to overwrite any arbitrary part of the config.
Upvotes: 2