amperity / envoy Goto Github PK
View Code? Open in Web Editor NEWWatching your Clojure environment configs...
License: Other
Watching your Clojure environment configs...
License: Other
user=> (defenv :bar "boolean" :type :boolean)
{:type :boolean, :ns user, :line 1, :description "boolean"}
user=> (envoy.core/set-env! :bar "true")
nil
user=> (envoy.core/env :bar)
true
user=> (envoy.core/set-env! :bar "false")
nil
user=> (envoy.core/env :bar)
"false"
user=> (envoy.core/set-env! :bar "f")
nil
user=> (envoy.core/env :bar)
"f"
It looks like it's impossible to get a boolean false
value; truthy values are coerced to a boolean but "falsey" values are not.
Hey there ๐ I just came by by random chance and noticed that you have a badge for API docs in your readme but that those are outdated. And so I wanted to make you aware of envoy's docs on cljdoc that you could use for API documentation and more.
There's also a badge and a URL that always points to the most recent release version:
[![envoy cljdoc badge](https://cljdoc.xyz/badge/amperity/envoy)](https://cljdoc.xyz/d/amperity/envoy/CURRENT)
It's all open source in case you're curious: https://github.com/cljdoc/cljdoc
It would be nice, if the following would be supported:
(defenv :my-var
"Trigger nice stuff [default: 1234]"
:default 1234)
Or this more generic variant:
(defenv :my-var
"Trigger nice stuff [default: 1234]"
:default (fn [] 1234))
That way I would not have to spread (possibly different) default values throughout my code, wherever I access the env var. All calls of (env :my-var)
would behave like (env :my-var 1234)
.
I encountered this when setting up some tests that override environment variable values.
amperity.stitch.e2e-test> (def e (envoy/env-map))
#'amperity.stitch.e2e-test/e
amperity.stitch.e2e-test> e
EnvironmentMap {}
amperity.stitch.e2e-test> (merge e {:asdf 1})
EnvironmentMap ({} [:asdf 1])
Perhaps this is expected behavior, if so, what is the justification? I'm finding it would be convenient in test to merge values on top of envoy/env
.
Using select-keys
on an environment map uses find
internally, which will throw an exception when passed a envoy.core.EnvironmentMap
.
(require '[envoy.core :as env :refer [defenv env]])
(defenv :test-bool
"A boolean field"
:type :boolean)
(get env :test-bool)
;; => nil
(env :test-bool)
;; => nil
(find env :test-bool)
;; =>
;; 1. Unhandled clojure.lang.ExceptionInfo
;; Cannot parse non-string value to boolean
(select-keys env [:test-bool])
;; =>
;; 1. Unhandled clojure.lang.ExceptionInfo
;; Cannot parse non-string value to boolean
It would be nice if the following would work:
(ns myenv (:require [envoy.core :refer [defenv]]))
(defenv ::the-var "The var" :type :string)
(ns other (:require [envoy.core :refer [env]] [myenv :as env]))
(env ::env/the-var)
Currently, they are treated as undeclared:
[envoy.check:286] - Overriding undeclared env variable :envoy.core/the-var
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.