Add cprop example (#648) [skip ci]
This commit is contained in:
parent
99a747e951
commit
bc47d858a0
4 changed files with 107 additions and 1 deletions
|
|
@ -283,7 +283,7 @@ which finds unused vars. It uses
|
|||
$ bb examples/hsqldb_unused_vars.clj src
|
||||
|
||||
| :VARS/NS | :VARS/NAME | :VARS/FILENAME | :VARS/ROW | :VARS/COL |
|
||||
|----------------------------+--------------------------+------------------------------------+-----------+-----------|
|
||||
|----------------------------|--------------------------|------------------------------------|-----------|-----------|
|
||||
| babashka.impl.bencode.core | read-netstring | src/babashka/impl/bencode/core.clj | 162 | 1 |
|
||||
| babashka.impl.bencode.core | write-netstring | src/babashka/impl/bencode/core.clj | 201 | 1 |
|
||||
| babashka.impl.classes | generate-reflection-file | src/babashka/impl/classes.clj | 230 | 1 |
|
||||
|
|
@ -345,3 +345,15 @@ $ examples/torrent-viewer.clj file.torrent
|
|||
```
|
||||
|
||||
See [torrent-viewer.clj](torrent-viewer.clj).
|
||||
|
||||
### [cprop.clj](cprop.clj)
|
||||
|
||||
This script uses [tolitius/cprop](https://github.com/tolitius/cprop) library.
|
||||
|
||||
See [cprop.clj](cprop.clj)
|
||||
|
||||
Example usage:
|
||||
|
||||
```shell
|
||||
cd ./examples && chmod +x cprop.clj && ./cprop.clj
|
||||
```
|
||||
|
|
|
|||
12
examples/cprop-override.properties
Normal file
12
examples/cprop-override.properties
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
datomic.url=datomic:sql://?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic
|
||||
|
||||
source.account.rabbit.host=localhost
|
||||
|
||||
aws.access-key=super secret key
|
||||
aws.secret_key=super secret s3cr3t!!!
|
||||
aws.region=us-east-2
|
||||
|
||||
io.http.pool.conn_timeout=42
|
||||
io.http.pool.max_per_route=42
|
||||
|
||||
other_things=1,2,3,4,5,6,7
|
||||
56
examples/cprop.clj
Executable file
56
examples/cprop.clj
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env bb
|
||||
(require '[babashka.classpath :refer [add-classpath]])
|
||||
(require '[clojure.java.shell :refer [sh]])
|
||||
(require '[clojure.pprint :refer [pprint]])
|
||||
|
||||
(def deps '{:deps {cprop {:mvn/version "0.1.17"}}})
|
||||
(def cp (:out (sh "clojure" "-Spath" "-Sdeps" (str deps))))
|
||||
(add-classpath cp)
|
||||
|
||||
(require '[cprop.core :refer [load-config]])
|
||||
(require '[cprop.source :refer [from-props-file]])
|
||||
|
||||
;; Load sample configuration from the file system
|
||||
(def conf (load-config :file "cprop.edn"))
|
||||
|
||||
;; Print the configuration we just read in
|
||||
(pprint conf)
|
||||
|
||||
;;=>
|
||||
#_{:datomic {:url "CHANGE ME"}
|
||||
:aws {:access-key "AND ME"
|
||||
:secret-key "ME TOO"
|
||||
:region "FILL ME IN AS WELL"
|
||||
:visiblity-timeout-sec 30
|
||||
:max-conn 50
|
||||
:queue "cprop-dev"}
|
||||
:io {:http {:pool {:socket-timeout 600000
|
||||
:conn-timeout :I-SHOULD-BE-A-NUMBER
|
||||
:conn-req-timeout 600000
|
||||
:max-total 200
|
||||
:max-per-route :ME-ALSO}}}
|
||||
:other-things ["I am a vector and also like to place the substitute game"]}
|
||||
(let [conf (load-config
|
||||
:file "cprop.edn"
|
||||
:merge [(from-props-file "cprop-override.properties")])]
|
||||
(pprint conf))
|
||||
|
||||
;;=>
|
||||
#_{:datomic
|
||||
{:url "datomic:sql://?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic"},
|
||||
:aws
|
||||
{:access-key "super secret key",
|
||||
:secret-key "super secret s3cr3t!!!",
|
||||
:region "us-east-2",
|
||||
:visiblity-timeout-sec 30,
|
||||
:max-conn 50,
|
||||
:queue "cprop-dev"},
|
||||
:io
|
||||
{:http
|
||||
{:pool
|
||||
{:socket-timeout 600000,
|
||||
:conn-timeout 42,
|
||||
:conn-req-timeout 600000,
|
||||
:max-total 200,
|
||||
:max-per-route 42}}},
|
||||
:other-things ["1" "2" "3" "4" "5" "6" "7"]}
|
||||
26
examples/cprop.edn
Normal file
26
examples/cprop.edn
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#_
|
||||
{:datomic
|
||||
{:url "datomic:sql://?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic"}
|
||||
:source
|
||||
{:account
|
||||
{:rabbit
|
||||
{:host "127.0.0.1"
|
||||
:port 5672
|
||||
:vhost "/z-broker"
|
||||
:username "guest"
|
||||
:password "guest"}}}
|
||||
:answer 42}
|
||||
|
||||
{:datomic {:url "CHANGE ME"}
|
||||
:aws {:access-key "AND ME"
|
||||
:secret-key "ME TOO"
|
||||
:region "FILL ME IN AS WELL"
|
||||
:visiblity-timeout-sec 30
|
||||
:max-conn 50
|
||||
:queue "cprop-dev"}
|
||||
:io {:http {:pool {:socket-timeout 600000
|
||||
:conn-timeout :I-SHOULD-BE-A-NUMBER
|
||||
:conn-req-timeout 600000
|
||||
:max-total 200
|
||||
:max-per-route :ME-ALSO}}}
|
||||
:other-things ["I am a vector and also like to place the substitute game"]}
|
||||
Loading…
Reference in a new issue