Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the envy Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 13:23:35 2020 GMT+0.
• Introduction | What envy is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Configuration switcher by an environment variable inspired by Perl's Config::ENV.
(defpackage :myapp.config
(:use :cl
:envy))
(in-package :myapp.config)
(setf (config-env-var) "APP_ENV")
(defconfig :common
`(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))
(defconfig |development|
'(:debug T
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))
(defconfig |production|
'(:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))
(defconfig |staging|
`(:debug T
,@|production|))
(defpackage :myapp
(:use :cl)
(:import-from :envy
:config)
(in-package :myapp)
(getf (config :myapp.config) :database-type)
Envy is a configuration manager for various applications.
Envy uses an environment variable to determine a configuration to use. I'm not sure this is ideal even for Common Lisp applications, but this can separate configuration system from an implementation.
ENVY:DEFCONFIG
is a macro for defining a named configuration.
Don't forget to set (ENVY:CONFIG-ENV-VAR)
which is a name of environment variable to determine a configuration.
(setf (config-env-var) "APP_ENV")
;; Use SQLite3 for development
(defconfig |development|
'(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))
;; Use MySQL in production environment
(defconfig |production|
'(:server :fcgi
:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))
Each configurations are represented as property lists. It means you can merge them by the default way of merging lists -- cons, append or/and splicing unquote.
(defconfig |staging|
`(:server :hunchentoot
,@|production|))
You can also define a common configuration which will be merged into every configurations.
(defconfig :common
`(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))
ENVY:CONFIG
is an accessor to get the current configuration.
(config :<configuration-package-name>)
(config :myapp.config)
;=> '(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")
:application-root #P"/path/to/application/")
(getf (config :myapp.config) :database-type)
;=> :sqlite3
(defpackage myapp.config
(:use :cl
:envy)
(:shadow :envy
:config)
(:export :config))
(in-package :myapp.config)
(defconfig :common
...)
;;
;; ... Configurations ...
;;
(defun config ()
(envy:config #.(package-name *package*)))
Thank cho45 for the great product. I feel envy to you :)
Copyright (c) 2013 Eitarow Fukamachi (e.arrows@gmail.com)
Licensed under the BSD 2-Clause License.
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The envy system |
Eitarow Fukamachi
BSD 2-Clause
Configuration switcher by an environment variable.
# Envy
Configuration switcher by an environment variable inspired by Perl’s [Config::ENV](http://search.cpan.org/~satoh/Config-ENV/lib/Config/ENV.pm).
## Usage
“‘common-lisp
(defpackage :myapp.config
(:use :cl
:envy))
(in-package :myapp.config)
(setf (config-env-var) "APP_ENV")
(defconfig :common
‘(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))
(defconfig |development|
’(:debug T
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))
(defconfig |production|
’(:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))
(defconfig |staging|
‘(:debug T
,@|production|))
“‘
“‘common-lisp
(defpackage :myapp
(:use :cl)
(:import-from :envy
:config)
(in-package :myapp)
(getf (config :myapp.config) :database-type)
“‘
## Description
Envy is a configuration manager for various applications.
Envy uses an environment variable to determine a configuration to use. I’m not sure this is ideal even for Common Lisp applications, but this can separate configuration system from an implementation.
## Configurations
### Normal configurations
‘ENVY:DEFCONFIG‘ is a macro for defining a named configuration.
Don’t forget to set ‘(ENVY:CONFIG-ENV-VAR)‘ which is a name of environment variable to determine a configuration.
“‘common-lisp
(setf (config-env-var) "APP_ENV")
;; Use SQLite3 for development
(defconfig |development|
’(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))
;; Use MySQL in production environment
(defconfig |production|
’(:server :fcgi
:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))
“‘
### Merging
Each configurations are represented as property lists. It means you can merge them by the default way of merging lists – cons, append or/and splicing unquote.
“‘common-lisp
(defconfig |staging|
‘(:server :hunchentoot
,@|production|))
“‘
### Common configurations
You can also define a common configuration which will be merged into every configurations.
“‘common-lisp
(defconfig :common
‘(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))
“‘
### Accessing to configuration
‘ENVY:CONFIG‘ is an accessor to get the current configuration.
“‘common-lisp
(config :<configuration-package-name>)
(config :myapp.config)
;=> ’(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")
:application-root #P"/path/to/application/")
(getf (config :myapp.config) :database-type)
;=> :sqlite3
“‘
## Tips
“‘common-lisp
(defpackage myapp.config
(:use :cl
:envy)
(:shadow :envy
:config)
(:export :config))
(in-package :myapp.config)
(defconfig :common
...)
;;
;; ... Configurations ...
;;
(defun config ()
(envy:config #.(package-name *package*)))
“‘
## See Also
Thank cho45 for the great product. I feel envy to you :)
- [Config::ENV](http://search.cpan.org/~satoh/Config-ENV/lib/Config/ENV.pm)
## Author
* Eitarow Fukamachi (e.arrows@gmail.com)
## Copyright
Copyright (c) 2013 Eitarow Fukamachi (e.arrows@gmail.com)
# License
Licensed under the BSD 2-Clause License.
0.1
envy.asd (file)
src (module)
Modules are listed depth-first from the system components tree.
• The envy/src module |
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The envy.asd file | ||
• The envy/src/envy.lisp file |
Next: The envy/src/envy․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
Previous: The envy․asd file, Up: Lisp files [Contents][Index]
src (module)
src/envy.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The envy-asd package | ||
• The envy package |
Next: The envy package, Previous: Packages, Up: Packages [Contents][Index]
envy.asd
Previous: The envy-asd package, Up: Packages [Contents][Index]
envy.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros | ||
• Exported functions |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Previous: Exported macros, Up: Exported definitions [Contents][Index]
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
Previous: Internal special variables, Up: Internal definitions [Contents][Index]
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | E F L M |
---|
Jump to: | E F L M |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
C D F M P |
---|
Jump to: | (
C D F M P |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
S |
---|
Jump to: | *
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | E P S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
E | |||
envy : | The envy system | ||
envy : | The envy package | ||
envy-asd : | The envy-asd package | ||
| |||
P | |||
Package, envy : | The envy package | ||
Package, envy-asd : | The envy-asd package | ||
| |||
S | |||
System, envy : | The envy system | ||
|
Jump to: | E P S |
---|