| 1 |
|
%% Copyright (c) 2022 Peter Morgan <peter.james.morgan@gmail.com> |
| 2 |
|
%% |
| 3 |
|
%% Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
|
%% you may not use this file except in compliance with the License. |
| 5 |
|
%% You may obtain a copy of the License at |
| 6 |
|
%% |
| 7 |
|
%% http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
|
%% |
| 9 |
|
%% Unless required by applicable law or agreed to in writing, software |
| 10 |
|
%% distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
|
%% See the License for the specific language governing permissions and |
| 13 |
|
%% limitations under the License. |
| 14 |
|
|
| 15 |
|
|
| 16 |
|
-module(mcd_config). |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
-export([maximum/1]). |
| 20 |
|
-export([memcached/1]). |
| 21 |
|
-export([protocol/1]). |
| 22 |
|
-export([socket/1]). |
| 23 |
|
-export([telemetry/1]). |
| 24 |
|
-import(envy, [envy/1]). |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
maximum(value_size = Name) -> |
| 28 |
43 |
envy(#{caller => ?MODULE, |
| 29 |
|
names => [?FUNCTION_NAME, Name], |
| 30 |
|
default => 1024 * 1024}). |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
memcached(port = Name) -> |
| 34 |
22 |
envy(#{caller => ?MODULE, |
| 35 |
|
names => [?FUNCTION_NAME, Name], |
| 36 |
|
default => 11211}); |
| 37 |
|
memcached(hostname = Name) -> |
| 38 |
11 |
envy(#{caller => ?MODULE, |
| 39 |
|
names => [?FUNCTION_NAME, Name], |
| 40 |
|
default => "localhost"}). |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
socket(backlog = Name) -> |
| 44 |
11 |
envy(#{caller => ?MODULE, |
| 45 |
|
names => [?FUNCTION_NAME, Name], |
| 46 |
|
default => 5}). |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
protocol(callback = Name) -> |
| 50 |
11 |
envy(#{caller => ?MODULE, |
| 51 |
|
type => atom, |
| 52 |
|
names =>[?FUNCTION_NAME, Name]}). |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
telemetry(Name) when Name == module; Name == function -> |
| 56 |
11 |
envy(#{caller => ?MODULE, |
| 57 |
|
type => atom, |
| 58 |
|
names =>[?FUNCTION_NAME, Name]}); |
| 59 |
|
|
| 60 |
|
telemetry(event_names = Name) -> |
| 61 |
:-( |
envy(#{caller => ?MODULE, |
| 62 |
|
names => [?FUNCTION_NAME, Name], |
| 63 |
|
default => filename:join(mcd:priv_dir(), "telemetry.terms")}); |
| 64 |
|
|
| 65 |
|
telemetry(config = Name) -> |
| 66 |
:-( |
envy:get_env(mcd, |
| 67 |
|
mcd_util:snake_case([?FUNCTION_NAME, Name]), |
| 68 |
|
[app_env, {default, []}]). |