Skip to content

Instantly share code, notes, and snippets.

@emidln
Created December 30, 2015 23:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emidln/005fa93f70744cc5fe5f to your computer and use it in GitHub Desktop.
Save emidln/005fa93f70744cc5fe5f to your computer and use it in GitHub Desktop.
(ns curiosity.analytics.web.settings
(:require [schema.core :as s]
[schema-contrib.core :as sc]
[plumbing.core :refer [map-vals]]))
;; This is used to resolve environment variable names
;; (and java properties) with minimal conflicts.
(def project-name "analytics")
;; Settings will get resolved in the following
;; order (first one wins) after prepending project-name:
;;
;; java property (dashes to periods)
;; environment variables (dashes to underscores, toUpper everything)
;; defaults
;; nil
;;
;; For example `debug` translates to :debug which looks up
;;
;; java property: notify.debug
;; environ variable: NOTIFY_DEBUG
;; default value :debug value
;; nil
(def settings
"Map of setting name to a map containing :schema and :default"
{:debug {:schema s/Bool :default false}
:db-uri {:schema sc/URI :default "postgres://localhost:5432/userevents"}
:redis-uri {:schema sc/URI :default "redis://localhost:6379/0"}
:nrepl-port {:schema s/Int :default 7234}
:http-ip {:schema s/Str :default "127.0.0.1"}
:http-port {:schema s/Int :default 8080}
:sentry-dsn {:schema (s/maybe s/Str) :default nil}
:curiosity-environment {:schema s/Str :default "dev"}})
;; Our system initialization wants maps of the settings-schema
;; as well as the settings-defaults for processing in stages.
(def settings-schema (map-vals :schema settings))
(def settings-defaults (map-vals :default settings))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment