Handling setting different "profiles" between different environments

46 views
Skip to first unread message

Dave Kincaid

unread,
Aug 14, 2012, 8:49:58 PM8/14/12
to clo...@googlegroups.com
Being new to functional programming and Lisp in particular there is something that's been bugging me for a while. How do people handle having different configurations during development for development, testing and production? For example, things like data sources, server names, etc are often different when you're developing, testing and deploying to production. In Java-land the Spring framework profiles work really well for doing this. Just specify a profile name as a program argument and global variables are setup appropriately.

So I'm wondering how others handle this. In one project recently I setup a global map using ^:dynamic and then switched in the appropriate map from a command line argument. This somehow doesn't seem the right way to do it. Any suggestions? Are there some projects out there that would be good examples of this?

Thanks,

Dave

Sean Corfield

unread,
Aug 14, 2012, 9:33:49 PM8/14/12
to clo...@googlegroups.com
On Tue, Aug 14, 2012 at 5:49 PM, Dave Kincaid <kincai...@gmail.com> wrote:
> So I'm wondering how others handle this. In one project recently I setup a
> global map using ^:dynamic and then switched in the appropriate map from a
> command line argument. This somehow doesn't seem the right way to do it. Any
> suggestions? Are there some projects out there that would be good examples
> of this?

At World Singles, environment control was one of the first things we
switched over to Clojure.

Essentially we have a map of maps - a map with default settings and
then a map for each environment with overrides - and a settings Var
that is a delay of creating the merged map for the current host (by
looking up the local hostname in the override maps). That's a gross
simplification but it should give you an idea of what we're doing.

The application just accesses @worldsingles.environment/settings and
it's created on first access and cached for subsequent access (because
of delay).
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Dave Kincaid

unread,
Aug 14, 2012, 10:44:27 PM8/14/12
to clo...@googlegroups.com
Thanks, Sean. I really like that approach. I wasn't even aware of the delay macro. Very cool. So much awesome stuff in Clojure I feel like I'll never learn it all.

Nelson Morris

unread,
Aug 15, 2012, 1:05:00 AM8/15/12
to clo...@googlegroups.com
I've been using lein2's profiles combined with
https://github.com/weavejester/environ recently. The :dev and :test
profiles can declare the keys for their setup, and production can
declare them as environmental variables.
Reply all
Reply to author
Forward
0 new messages