aboutsummaryrefslogtreecommitdiff
path: root/apps/dreki/src/dreki_config.erl
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dreki/src/dreki_config.erl')
-rw-r--r--apps/dreki/src/dreki_config.erl26
1 files changed, 23 insertions, 3 deletions
diff --git a/apps/dreki/src/dreki_config.erl b/apps/dreki/src/dreki_config.erl
index 69df2d6..457f559 100644
--- a/apps/dreki/src/dreki_config.erl
+++ b/apps/dreki/src/dreki_config.erl
@@ -2,8 +2,14 @@
-include_lib("kernel/include/logger.hrl").
-include_lib("partisan/include/partisan.hrl").
-include("dreki_plum.hrl").
+-include("dreki_otel.hrl").
+
+-compile({no_auto_import,[get/0]}).
+
-export([init/1]).
+-export([get/1]).
+-export([set/2]).
-define(CONFIG, [
%% All stolen from bondy as partisan isn't that well documented, eh.
@@ -44,15 +50,29 @@
-define(PT, dreki_config_cache).
init(_Args) ->
- persistent_term:put(?PT, application:get_all_env(dreki)),
+ persistent_term:put(?PT, [{dreki, application:get_all_env(dreki)},
+ {dreki_web, application:get_all_env(dreki_web)
+ }]),
ok = set_app_configs(?CONFIG),
- ?LOG_INFO(#{message => "Configured Dreki and dependencies"}),
+ ?LOG_NOTICE(#{message => "Configured Dreki and dependencies"}),
ok = partisan_config:init(),
ok.
+get() ->
+ persistent_term:get(?PT).
+
+get(Key) ->
+ ?with_span(?FUN_NAME, #{}, fun (_) -> key_value:get(Key, get()) end).
+
+set(Key, Value) ->
+ ?with_span(?FUN_NAME, #{},
+ fun (_) ->
+ persistent_term:put(?PT, key_value:put(Key, Value, get())),
+ ok
+ end).
+
set_app_configs(Configs) ->
lists:foreach(fun ({App, Params}) ->
[application:set_env(App, Key, Value) || {Key, Value} <- Params]
end, Configs),
ok.
-