Player FM - Internet Radio Done Right
94 subscribers
Checked 12M ago
اضافه شده در seven سال پیش
محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمتها، گرافیکها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آنها آپلود و ارائه میشوند. اگر فکر میکنید شخصی بدون اجازه شما از اثر دارای حق نسخهبرداری شما استفاده میکند، میتوانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal
Player FM - برنامه پادکست
با برنامه Player FM !
با برنامه Player FM !
پادکست هایی که ارزش شنیدن دارند
حمایت شده
Sidhu Moose Wala explodes onto the Canadian music scene. His sound is a fusion of two worlds - hip-hop with the poetic language of rural Punjab, where he is from. After years of struggle he’s making it. But with the spotlight comes a dark side. As his fame grows, so do the threats. "We will kill you." Presented by broadcaster and DJ Bobby Friction and investigative journalist Ishleen Kaur. Season 8 of World of Secrets, The Killing Call, is a BBC Eye investigation for the BBC World Service. Archive audio credits: Lovepreet Waraich, Malwa TV, BritAsia TV, MPHONE Canteeni Mandeer, GK Digital, Thakur Media, Capital Extra, Famous Punjab TV, ModernSings, Dheeth.jeha, RealRohitBlogs, Mirror Now, India Today. Here’s a link to the BBC Eye two-part documentary films, which we recommend you watch after listening to this podcast: https://bit.ly/thekillingcall If you are in the UK, you can watch on iPlayer: https://www.bbc.co.uk/programmes/m002f18y…
Episode 011: The Convention of Configuration
Manage episode 224930934 series 2463849
محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمتها، گرافیکها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آنها آپلود و ارائه میشوند. اگر فکر میکنید شخصی بدون اجازه شما از اثر دارای حق نسخهبرداری شما استفاده میکند، میتوانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal
Nate is worried about the hardcoded credentials in the code.
- It's episode 011 on 01/11. It's binary!
- "As a developer, you quickly learn what's under your control and what's not. Very little is under your control."
- Don't accidentally check in the credentials.
- "We need a configuration management system. Oh wait! That's a totally different problem."
- What about putting the configuration into an EDN file?
- Let's call it
config.edn
- Why EDN? Isn't JSON the "one, true format for config information"?
- Pros of EDN:
- native to Clojure
- can have comments
- is extensible
- Why not environment variables?
- Environment variables are great for production, but in development files are better.
- Have to restart the REPL to change env variables.
- Make a component that reads the config. That will reload config when you
reset
with component.repl. - Two main considerations:
- Dynamically reloading configuration during development
- Plumbing the configuration values through the app
- Make a namespace for
app.config
- "Files are way more fungible than the environment."
- We want both options: env for production and a file for dev.
- Make two functions in
app.config
:from-env
andfrom-file
. - Use schema to make sure both functions return the same config map.
- "A thing I have done before...you decide if it's clever."
- Define a default configuration and then
merge
the config maps with that. - Better yet,
from-env
handles defaults and wemerge
the map fromdev.edn
into that. - Can use
environ
with Leiningen profiles. Still requires restarting the REPL. - Defaults should make sense for development, so you can just check out and run.
- For bad config, we want helpful error messages, not stack traces.
- What goes in configuration?
- Items under your control
- Items that vary
- Twitter API URL does not vary.
- Even if Twitter provided sandbox URLs, those URLs don't vary. The config option should be "production" and "sandbox", not the URL. The wrapper code will select the right URL.
- Avoid the nonsense of trying to infer "sandbox" from reading the URL.
- "The hallmark of good design is: the less thinking you have to do, the better."
- "The more semantic the config, the less thinking you have to do."
- It's important to think about the data first, where it comes from, and where it goes.
Clojure in this episode:
merge
try
,catch
slurp
clojure.edn/read-string
environ.core/env
component.repl/reset
Related projects:
Code sample from this episode:
(ns app.config (:require [clojure.edn :as edn] [environ.core :refer [env]])) (defn from-env [] {:twitter-key (or (env :twitter-key) "") :twitter-secret (or (env :twitter-secret) "") :initial-tweets (or (env :initial-tweets) 20)) (defn config [] (merge (from-env) (edn/read-string (try (slurp "dev.edn") (catch Throwable e "{}")))))
118 قسمت
Manage episode 224930934 series 2463849
محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمتها، گرافیکها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آنها آپلود و ارائه میشوند. اگر فکر میکنید شخصی بدون اجازه شما از اثر دارای حق نسخهبرداری شما استفاده میکند، میتوانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal
Nate is worried about the hardcoded credentials in the code.
- It's episode 011 on 01/11. It's binary!
- "As a developer, you quickly learn what's under your control and what's not. Very little is under your control."
- Don't accidentally check in the credentials.
- "We need a configuration management system. Oh wait! That's a totally different problem."
- What about putting the configuration into an EDN file?
- Let's call it
config.edn
- Why EDN? Isn't JSON the "one, true format for config information"?
- Pros of EDN:
- native to Clojure
- can have comments
- is extensible
- Why not environment variables?
- Environment variables are great for production, but in development files are better.
- Have to restart the REPL to change env variables.
- Make a component that reads the config. That will reload config when you
reset
with component.repl. - Two main considerations:
- Dynamically reloading configuration during development
- Plumbing the configuration values through the app
- Make a namespace for
app.config
- "Files are way more fungible than the environment."
- We want both options: env for production and a file for dev.
- Make two functions in
app.config
:from-env
andfrom-file
. - Use schema to make sure both functions return the same config map.
- "A thing I have done before...you decide if it's clever."
- Define a default configuration and then
merge
the config maps with that. - Better yet,
from-env
handles defaults and wemerge
the map fromdev.edn
into that. - Can use
environ
with Leiningen profiles. Still requires restarting the REPL. - Defaults should make sense for development, so you can just check out and run.
- For bad config, we want helpful error messages, not stack traces.
- What goes in configuration?
- Items under your control
- Items that vary
- Twitter API URL does not vary.
- Even if Twitter provided sandbox URLs, those URLs don't vary. The config option should be "production" and "sandbox", not the URL. The wrapper code will select the right URL.
- Avoid the nonsense of trying to infer "sandbox" from reading the URL.
- "The hallmark of good design is: the less thinking you have to do, the better."
- "The more semantic the config, the less thinking you have to do."
- It's important to think about the data first, where it comes from, and where it goes.
Clojure in this episode:
merge
try
,catch
slurp
clojure.edn/read-string
environ.core/env
component.repl/reset
Related projects:
Code sample from this episode:
(ns app.config (:require [clojure.edn :as edn] [environ.core :refer [env]])) (defn from-env [] {:twitter-key (or (env :twitter-key) "") :twitter-secret (or (env :twitter-secret) "") :initial-tweets (or (env :initial-tweets) 20)) (defn config [] (merge (from-env) (edn/read-string (try (slurp "dev.edn") (catch Throwable e "{}")))))
118 قسمت
All episodes
×به Player FM خوش آمدید!
Player FM در سراسر وب را برای یافتن پادکست های با کیفیت اسکن می کند تا همین الان لذت ببرید. این بهترین برنامه ی پادکست است که در اندروید، آیفون و وب کار می کند. ثبت نام کنید تا اشتراک های شما در بین دستگاه های مختلف همگام سازی شود.