chore: add some example annotations for config importance level

This commit is contained in:
Zaiming (Stone) Shi 2023-03-27 16:10:36 +02:00
parent 5a19b6f73e
commit d07987288a
9 changed files with 54 additions and 24 deletions

View File

@ -230,7 +230,7 @@ roots(low) ->
{"crl_cache",
sc(
ref("crl_cache"),
#{hidden => true}
#{importance => ?IMPORTANCE_HIDDEN}
)}
].
@ -1492,7 +1492,7 @@ fields("broker") ->
{"perf",
sc(
ref("broker_perf"),
#{hidden => true}
#{importance => ?IMPORTANCE_HIDDEN}
)},
{"shared_subscription_group",
sc(
@ -2997,7 +2997,7 @@ quic_feature_toggle(Desc) ->
typerefl:alias("boolean", typerefl:union([true, false, 0, 1])),
#{
desc => Desc,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
required => false,
converter => fun
(true) -> 1;
@ -3012,7 +3012,7 @@ quic_lowlevel_settings_uint(Low, High, Desc) ->
range(Low, High),
#{
required => false,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
desc => Desc
}
).

View File

@ -1,6 +1,6 @@
{application, emqx_conf, [
{description, "EMQX configuration management"},
{vsn, "0.1.14"},
{vsn, "0.1.15"},
{registered, []},
{mod, {emqx_conf_app, []}},
{applications, [kernel, stdlib, emqx_ctl]},

View File

@ -158,9 +158,13 @@ gen_schema_json(Dir, I18nFile, SchemaModule, Lang) ->
io:format(user, "===< Generating: ~s~n", [SchemaJsonFile]),
%% EMQX_SCHEMA_FULL_DUMP is quite a hidden API
%% it is used to dump the full schema for EMQX developers and supporters
IncludeHidden = (os:getenv("EMQX_SCHEMA_FULL_DUMP") =:= "1"),
IncludeHidden andalso io:format(user, "===< Including hidden fields~n", []),
Opts = #{desc_file => I18nFile, lang => Lang, include_hidden_fields => IncludeHidden},
IncludeImportance =
case os:getenv("EMQX_SCHEMA_FULL_DUMP") =:= "1" of
true -> ?IMPORTANCE_HIDDEN;
false -> ?IMPORTANCE_LOW
end,
io:format(user, "===< Including fields from importance level: ~p~n", [IncludeImportance]),
Opts = #{desc_file => I18nFile, lang => Lang, include_importance_up_from => IncludeImportance},
JsonMap = hocon_schema_json:gen(SchemaModule, Opts),
IoData = jsx:encode(JsonMap, [space, {indent, 4}]),
ok = file:write_file(SchemaJsonFile, IoData).
@ -224,7 +228,8 @@ gen_example(File, SchemaModule, I18nFile, Lang) ->
title => <<"EMQX Configuration Example">>,
body => <<"">>,
desc_file => I18nFile,
lang => Lang
lang => Lang,
include_importance_up_from => ?IMPORTANCE_MEDIUM
},
Example = hocon_schema_example:gen(SchemaModule, Opts),
file:write_file(File, Example).

View File

@ -397,6 +397,7 @@ fields("node") ->
#{
default => <<"emqx@127.0.0.1">>,
'readOnly' => true,
importance => ?IMPORTANCE_HIGH,
desc => ?DESC(node_name)
}
)},
@ -409,6 +410,7 @@ fields("node") ->
'readOnly' => true,
sensitive => true,
desc => ?DESC(node_cookie),
importance => ?IMPORTANCE_HIGH,
converter => fun emqx_schema:password_converter/2
}
)},
@ -419,6 +421,7 @@ fields("node") ->
mapping => "vm_args.+P",
desc => ?DESC(process_limit),
default => 2097152,
importance => ?IMPORTANCE_MEDIUM,
'readOnly' => true
}
)},
@ -429,6 +432,7 @@ fields("node") ->
mapping => "vm_args.+Q",
desc => ?DESC(max_ports),
default => 1048576,
importance => ?IMPORTANCE_HIGH,
'readOnly' => true
}
)},
@ -439,6 +443,7 @@ fields("node") ->
mapping => "vm_args.+zdbbl",
desc => ?DESC(dist_buffer_size),
default => 8192,
importance => ?IMPORTANCE_LOW,
'readOnly' => true
}
)},
@ -449,6 +454,7 @@ fields("node") ->
mapping => "vm_args.+e",
desc => ?DESC(max_ets_tables),
default => 262144,
importance => ?IMPORTANCE_LOW,
'readOnly' => true
}
)},
@ -459,6 +465,10 @@ fields("node") ->
required => true,
'readOnly' => true,
mapping => "emqx.data_dir",
%% for now, it's tricky to use a different data_dir
%% otherwise data paths in cluster config may differ
%% TODO: change configurable data file paths to relative
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(node_data_dir)
}
)},
@ -467,7 +477,7 @@ fields("node") ->
hoconsc:array(string()),
#{
mapping => "emqx.config_files",
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
required => false,
'readOnly' => true
}
@ -479,6 +489,7 @@ fields("node") ->
mapping => "emqx_machine.global_gc_interval",
default => <<"15m">>,
desc => ?DESC(node_global_gc_interval),
importance => ?IMPORTANCE_LOW,
'readOnly' => true
}
)},
@ -489,6 +500,7 @@ fields("node") ->
mapping => "vm_args.-env ERL_CRASH_DUMP",
desc => ?DESC(node_crash_dump_file),
default => crash_dump_file_default(),
importance => ?IMPORTANCE_LOW,
'readOnly' => true
}
)},
@ -499,6 +511,7 @@ fields("node") ->
mapping => "vm_args.-env ERL_CRASH_DUMP_SECONDS",
default => <<"30s">>,
desc => ?DESC(node_crash_dump_seconds),
importance => ?IMPORTANCE_LOW,
'readOnly' => true
}
)},
@ -509,6 +522,7 @@ fields("node") ->
mapping => "vm_args.-env ERL_CRASH_DUMP_BYTES",
default => <<"100MB">>,
desc => ?DESC(node_crash_dump_bytes),
importance => ?IMPORTANCE_LOW,
'readOnly' => true
}
)},
@ -519,6 +533,7 @@ fields("node") ->
mapping => "vm_args.-kernel net_ticktime",
default => <<"2m">>,
'readOnly' => true,
importance => ?IMPORTANCE_LOW,
desc => ?DESC(node_dist_net_ticktime)
}
)},
@ -529,6 +544,7 @@ fields("node") ->
mapping => "emqx_machine.backtrace_depth",
default => 23,
'readOnly' => true,
importance => ?IMPORTANCE_LOW,
desc => ?DESC(node_backtrace_depth)
}
)},
@ -539,6 +555,7 @@ fields("node") ->
mapping => "emqx_machine.applications",
default => [],
'readOnly' => true,
importance => ?IMPORTANCE_LOW,
desc => ?DESC(node_applications)
}
)},
@ -548,13 +565,17 @@ fields("node") ->
#{
desc => ?DESC(node_etc_dir),
'readOnly' => true,
importance => ?IMPORTANCE_LOW,
deprecated => {since, "5.0.8"}
}
)},
{"cluster_call",
sc(
?R_REF("cluster_call"),
#{'readOnly' => true}
#{
'readOnly' => true,
importance => ?IMPORTANCE_LOW
}
)},
{"db_backend",
sc(
@ -563,6 +584,7 @@ fields("node") ->
mapping => "mria.db_backend",
default => rlog,
'readOnly' => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(db_backend)
}
)},
@ -573,6 +595,7 @@ fields("node") ->
mapping => "mria.node_role",
default => core,
'readOnly' => true,
importance => ?IMPORTANCE_HIGH,
desc => ?DESC(db_role)
}
)},
@ -583,6 +606,7 @@ fields("node") ->
mapping => "mria.rlog_rpc_module",
default => gen_rpc,
'readOnly' => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(db_rpc_module)
}
)},
@ -593,6 +617,7 @@ fields("node") ->
mapping => "mria.tlog_push_mode",
default => async,
'readOnly' => true,
importance => ?IMPORTANCE_LOW,
desc => ?DESC(db_tlog_push_mode)
}
)},
@ -601,7 +626,7 @@ fields("node") ->
hoconsc:enum([gen_rpc, distr]),
#{
mapping => "mria.shard_transport",
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
default => gen_rpc,
desc => ?DESC(db_default_shard_transport)
}
@ -611,7 +636,7 @@ fields("node") ->
map(shard, hoconsc:enum([gen_rpc, distr])),
#{
desc => ?DESC(db_shard_transports),
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
mapping => "emqx_machine.custom_shard_transports",
default => #{}
}

View File

@ -891,9 +891,9 @@ parse_object_loop([{Name, Hocon} | Rest], Module, Options, Props, Required, Refs
)
end.
%% return true if the field has 'importance' set to 'hidden'
is_hidden(Hocon) ->
hocon_schema:is_hidden(Hocon).
hocon_schema:is_hidden(Hocon, #{include_importance_up_from => ?IMPORTANCE_LOW}).
is_required(Hocon) ->
hocon_schema:field_schema(Hocon, required) =:= true.

View File

@ -2,7 +2,7 @@
{application, emqx_prometheus, [
{description, "Prometheus for EMQX"},
% strict semver, bump manually!
{vsn, "5.0.7"},
{vsn, "5.0.8"},
{modules, []},
{registered, [emqx_prometheus_sup]},
{applications, [kernel, stdlib, prometheus, emqx, emqx_management]},

View File

@ -90,7 +90,7 @@ fields("prometheus") ->
#{
default => enabled,
required => true,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(vm_dist_collector)
}
)},
@ -100,7 +100,7 @@ fields("prometheus") ->
#{
default => enabled,
required => true,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(mnesia_collector)
}
)},
@ -110,7 +110,7 @@ fields("prometheus") ->
#{
default => enabled,
required => true,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(vm_statistics_collector)
}
)},
@ -120,7 +120,7 @@ fields("prometheus") ->
#{
default => enabled,
required => true,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(vm_system_info_collector)
}
)},
@ -130,7 +130,7 @@ fields("prometheus") ->
#{
default => enabled,
required => true,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(vm_memory_collector)
}
)},
@ -140,7 +140,7 @@ fields("prometheus") ->
#{
default => enabled,
required => true,
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
desc => ?DESC(vm_msacc_collector)
}
)}

View File

@ -83,7 +83,7 @@ worker_pool_size(required) -> false;
worker_pool_size(_) -> undefined.
resume_interval(type) -> emqx_schema:duration_ms();
resume_interval(hidden) -> true;
resume_interval(importance) -> hidden;
resume_interval(desc) -> ?DESC("resume_interval");
resume_interval(required) -> false;
resume_interval(_) -> undefined.

View File

@ -364,7 +364,7 @@ fields(consumer_kafka_opts) ->
})},
{max_rejoin_attempts,
mk(non_neg_integer(), #{
hidden => true,
importance => ?IMPORTANCE_HIDDEN,
default => 5,
desc => ?DESC(consumer_max_rejoin_attempts)
})},