https://github.com/leancloud/clj-archaius
A Clojure library designed to use Netflix/archaius for configuration management.
https://github.com/leancloud/clj-archaius
Last synced: 11 months ago
JSON representation
A Clojure library designed to use Netflix/archaius for configuration management.
- Host: GitHub
- URL: https://github.com/leancloud/clj-archaius
- Owner: leancloud
- License: epl-1.0
- Created: 2015-07-02T09:02:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-03-19T10:27:17.000Z (about 5 years ago)
- Last Synced: 2025-04-21T03:20:55.708Z (11 months ago)
- Language: Clojure
- Homepage:
- Size: 11.7 KB
- Stars: 7
- Watchers: 18
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clj-archaius
A Clojure library designed to use [Netflix/archaius](https://github.com/Netflix/archaius/) for configuration management.
## Usage
Leiningen dependency:
```clj
[cn.leancloud/clj-archaius "0.4.1"]
```
Require clj-archaius in your namespace:
```
(require '[clj-archaius.core :refer :all])
```
Asume that you have a `config.properties` file in your project resource path:
```properties
a=1
b=2.0
c=hello\ world
```
You can get these properties by:
```clj
(int-env :a)
(double-env :b)
(env :c) ;;or (string-env :c)
```
With a default value if the property is not present:
```clj
(int-env :not-exists 100)
```
Add a callback listener to be notified when the property is changed:
```clj
(on-int-env :a (fn [] (println "The new :a is " (int-env :a))))
```
Supported types and their default values as below:
```
'int 0
'string nil
'boolean false
'double 0
'float 0
'long 0
```
All these types have `{type}-env` function to retrieve property value and `on-{type}-env`
function to add a callback listener to be notified when the property is changed.
## License
Copyright © 2015 dennis zhuang
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.