summaryrefslogtreecommitdiff
path: root/p11p-daemon/src/p11p_config.erl
diff options
context:
space:
mode:
Diffstat (limited to 'p11p-daemon/src/p11p_config.erl')
-rw-r--r--p11p-daemon/src/p11p_config.erl27
1 files changed, 23 insertions, 4 deletions
diff --git a/p11p-daemon/src/p11p_config.erl b/p11p-daemon/src/p11p_config.erl
index d24aad6..c4bfbcd 100644
--- a/p11p-daemon/src/p11p_config.erl
+++ b/p11p-daemon/src/p11p_config.erl
@@ -8,10 +8,16 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
-export([start_link/0]).
--export([nameof/1]).
--export([tokens/0]).
--export([proxyapp_bin_path/0, modules_for_token/1, module_path/1, module_env/1,
- token_balance/1, token_retries/1, token_timeout/1]).
+-export([modules_for_token/1,
+ module_path/1,
+ module_env/1,
+ nameof/1,
+ proxyapp_bin_path/0,
+ testing_drop_prob/0,
+ tokens/0,
+ token_balance/1,
+ token_retries/1,
+ token_timeout/1]).
%%% Records and types %%%
-record(p11module, {
@@ -32,6 +38,7 @@
-record(state, {
proxyapp_bin_path :: string(),
+ testing_drop_prob :: non_neg_integer(),
tokens :: #{string() => token()}
}).
@@ -46,6 +53,8 @@ init(_Args) ->
handle_call(proxyapp_bin_path, _From, S = #state{proxyapp_bin_path = Path}) ->
{reply, Path, S};
+handle_call(testing_drop_prob, _From, S = #state{testing_drop_prob = P}) ->
+ {reply, P, S};
handle_call(tokens, _From, State = #state{tokens = Tokens}) ->
{reply, maps:values(Tokens), State};
handle_call({modules_for_token, TokName}, _, S = #state{tokens = Tokens}) ->
@@ -86,6 +95,9 @@ start_link() ->
proxyapp_bin_path() ->
gen_server:call(?MODULE, proxyapp_bin_path).
+testing_drop_prob() ->
+ gen_server:call(?MODULE, testing_drop_prob).
+
-spec tokens() -> [token()].
tokens() ->
gen_server:call(?MODULE, tokens).
@@ -129,6 +141,9 @@ init_state() ->
proxyapp_bin_path = application:get_env(p11p,
proxyapp_bin_path,
?PROXYAPP_DEFAULT),
+ testing_drop_prob = application:get_env(p11p,
+ testing_drop_prob,
+ 0),
tokens = conf_tokens(application:get_env(p11p,
vtokens,
[]))}.
@@ -139,6 +154,10 @@ init_state(Filename) ->
string,
"proxyapp_bin_path",
?PROXYAPP_DEFAULT),
+ testing_drop_prob = p11p_config_file:get(Config,
+ integer,
+ "testing_drop_prob",
+ 0),
tokens = conf_tokens(p11p_config_file:get(Config,
section,
"vtokens",