chore: to_integer to make sure integer is converted
This commit is contained in:
parent
07172e42f0
commit
093cdab838
|
@ -2418,13 +2418,13 @@ mk_duration(Desc, OverrideMeta) ->
|
||||||
to_duration(Str) ->
|
to_duration(Str) ->
|
||||||
case hocon_postprocess:duration(Str) of
|
case hocon_postprocess:duration(Str) of
|
||||||
I when is_integer(I) -> {ok, I};
|
I when is_integer(I) -> {ok, I};
|
||||||
_ -> {error, Str}
|
_ -> to_integer(Str)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
to_duration_s(Str) ->
|
to_duration_s(Str) ->
|
||||||
case hocon_postprocess:duration(Str) of
|
case hocon_postprocess:duration(Str) of
|
||||||
I when is_number(I) -> {ok, ceiling(I / 1000)};
|
I when is_number(I) -> {ok, ceiling(I / 1000)};
|
||||||
_ -> {error, Str}
|
_ -> to_integer(Str)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec to_duration_ms(Input) -> {ok, integer()} | {error, Input} when
|
-spec to_duration_ms(Input) -> {ok, integer()} | {error, Input} when
|
||||||
|
@ -2432,7 +2432,7 @@ to_duration_s(Str) ->
|
||||||
to_duration_ms(Str) ->
|
to_duration_ms(Str) ->
|
||||||
case hocon_postprocess:duration(Str) of
|
case hocon_postprocess:duration(Str) of
|
||||||
I when is_number(I) -> {ok, ceiling(I)};
|
I when is_number(I) -> {ok, ceiling(I)};
|
||||||
_ -> {error, Str}
|
_ -> to_integer(Str)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec to_timeout_duration(Input) -> {ok, timeout_duration()} | {error, Input} when
|
-spec to_timeout_duration(Input) -> {ok, timeout_duration()} | {error, Input} when
|
||||||
|
@ -2473,7 +2473,7 @@ do_to_timeout_duration(Str, Fn, Max, Unit) ->
|
||||||
to_bytesize(Str) ->
|
to_bytesize(Str) ->
|
||||||
case hocon_postprocess:bytesize(Str) of
|
case hocon_postprocess:bytesize(Str) of
|
||||||
I when is_integer(I) -> {ok, I};
|
I when is_integer(I) -> {ok, I};
|
||||||
_ -> {error, Str}
|
_ -> to_integer(Str)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
to_wordsize(Str) ->
|
to_wordsize(Str) ->
|
||||||
|
@ -2483,6 +2483,13 @@ to_wordsize(Str) ->
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
to_integer(Str) when is_list(Str) ->
|
||||||
|
case string:to_integer(Str) of
|
||||||
|
{Int, []} -> {ok, Int};
|
||||||
|
{Int, <<>>} -> {ok, Int};
|
||||||
|
_ -> {error, Str}
|
||||||
|
end.
|
||||||
|
|
||||||
to_percent(Str) ->
|
to_percent(Str) ->
|
||||||
{ok, hocon_postprocess:percent(Str)}.
|
{ok, hocon_postprocess:percent(Str)}.
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,12 @@ init_per_testcase(t_ocsp_responder_error_responses, Config) ->
|
||||||
},
|
},
|
||||||
Conf = #{listeners => #{Type => #{Name => ListenerOpts}}},
|
Conf = #{listeners => #{Type => #{Name => ListenerOpts}}},
|
||||||
ConfBin = emqx_utils_maps:binary_key_map(Conf),
|
ConfBin = emqx_utils_maps:binary_key_map(Conf),
|
||||||
hocon_tconf:check_plain(emqx_schema, ConfBin, #{required => false, atom_keys => false}),
|
CheckedConf = hocon_tconf:check_plain(emqx_schema, ConfBin, #{
|
||||||
emqx_config:put_listener_conf(Type, Name, [], ListenerOpts),
|
required => false, atom_keys => false
|
||||||
|
}),
|
||||||
|
Conf2 = emqx_utils_maps:unsafe_atom_key_map(CheckedConf),
|
||||||
|
ListenerOpts2 = emqx_utils_maps:deep_get([listeners, Type, Name], Conf2),
|
||||||
|
emqx_config:put_listener_conf(Type, Name, [], ListenerOpts2),
|
||||||
snabbkaffe:start_trace(),
|
snabbkaffe:start_trace(),
|
||||||
_Heir = spawn_dummy_heir(),
|
_Heir = spawn_dummy_heir(),
|
||||||
{ok, CachePid} = emqx_ocsp_cache:start_link(),
|
{ok, CachePid} = emqx_ocsp_cache:start_link(),
|
||||||
|
@ -186,8 +190,12 @@ init_per_testcase(_TestCase, Config) ->
|
||||||
},
|
},
|
||||||
Conf = #{listeners => #{Type => #{Name => ListenerOpts}}},
|
Conf = #{listeners => #{Type => #{Name => ListenerOpts}}},
|
||||||
ConfBin = emqx_utils_maps:binary_key_map(Conf),
|
ConfBin = emqx_utils_maps:binary_key_map(Conf),
|
||||||
hocon_tconf:check_plain(emqx_schema, ConfBin, #{required => false, atom_keys => false}),
|
CheckedConf = hocon_tconf:check_plain(emqx_schema, ConfBin, #{
|
||||||
emqx_config:put_listener_conf(Type, Name, [], ListenerOpts),
|
required => false, atom_keys => false
|
||||||
|
}),
|
||||||
|
Conf2 = emqx_utils_maps:unsafe_atom_key_map(CheckedConf),
|
||||||
|
ListenerOpts2 = emqx_utils_maps:deep_get([listeners, Type, Name], Conf2),
|
||||||
|
emqx_config:put_listener_conf(Type, Name, [], ListenerOpts2),
|
||||||
[
|
[
|
||||||
{cache_pid, CachePid}
|
{cache_pid, CachePid}
|
||||||
| Config
|
| Config
|
||||||
|
|
|
@ -178,7 +178,7 @@ bridge_async_config(#{port := Port} = Config) ->
|
||||||
Name = maps:get(name, Config, ?BRIDGE_NAME),
|
Name = maps:get(name, Config, ?BRIDGE_NAME),
|
||||||
PoolSize = maps:get(pool_size, Config, 1),
|
PoolSize = maps:get(pool_size, Config, 1),
|
||||||
QueryMode = maps:get(query_mode, Config, "async"),
|
QueryMode = maps:get(query_mode, Config, "async"),
|
||||||
ConnectTimeout = maps:get(connect_timeout, Config, 1),
|
ConnectTimeout = maps:get(connect_timeout, Config, "1s"),
|
||||||
RequestTimeout = maps:get(request_timeout, Config, "10s"),
|
RequestTimeout = maps:get(request_timeout, Config, "10s"),
|
||||||
ResumeInterval = maps:get(resume_interval, Config, "1s"),
|
ResumeInterval = maps:get(resume_interval, Config, "1s"),
|
||||||
ResourceRequestTTL = maps:get(resource_request_ttl, Config, "infinity"),
|
ResourceRequestTTL = maps:get(resource_request_ttl, Config, "infinity"),
|
||||||
|
|
Loading…
Reference in New Issue