chore(gw): fix elvis warnings
This commit is contained in:
parent
f033fad7b3
commit
4f752fb5ab
|
@ -74,6 +74,8 @@
|
||||||
, serialize_error/1
|
, serialize_error/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
-elvis([{elvis_style, god_modules, disable}]).
|
||||||
|
|
||||||
api_spec() ->
|
api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ schema("/gateway/:name/authentication") ->
|
||||||
put =>
|
put =>
|
||||||
#{ description => <<"Update authentication for the gateway">>
|
#{ description => <<"Update authentication for the gateway">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, requestBody => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
, responses =>
|
, responses =>
|
||||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||||
|
@ -185,7 +185,7 @@ schema("/gateway/:name/authentication") ->
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Add authentication for the gateway">>
|
#{ description => <<"Add authentication for the gateway">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, requestBody => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
, responses =>
|
, responses =>
|
||||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||||
|
@ -289,7 +289,7 @@ schema("/gateway/:name/authentication/import_users") ->
|
||||||
, post =>
|
, post =>
|
||||||
#{ description => <<"Import users into the gateway authentication">>
|
#{ description => <<"Import users into the gateway authentication">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, requestBody => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
ref(emqx_authn_api, request_import_users),
|
ref(emqx_authn_api, request_import_users),
|
||||||
emqx_authn_api:request_import_users_examples()
|
emqx_authn_api:request_import_users_examples()
|
||||||
)
|
)
|
||||||
|
|
|
@ -179,7 +179,7 @@ schema("/gateway/:name/listeners") ->
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Create the gateway listener">>
|
#{ description => <<"Create the gateway listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, requestBody => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
ref(listener),
|
ref(listener),
|
||||||
examples_listener())
|
examples_listener())
|
||||||
, responses =>
|
, responses =>
|
||||||
|
@ -223,7 +223,7 @@ schema("/gateway/:name/listeners/:id") ->
|
||||||
#{ description => <<"Update the gateway listener">>
|
#{ description => <<"Update the gateway listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, requestBody => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
ref(listener),
|
ref(listener),
|
||||||
examples_listener())
|
examples_listener())
|
||||||
, responses =>
|
, responses =>
|
||||||
|
@ -254,7 +254,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
#{ description => <<"Add authentication for the listener">>
|
#{ description => <<"Add authentication for the listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, requestBody => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
, responses =>
|
, responses =>
|
||||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||||
|
@ -267,7 +267,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
#{ description => <<"Update authentication for the listener">>
|
#{ description => <<"Update authentication for the listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, requestBody => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
, responses =>
|
, responses =>
|
||||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
, listeners => []
|
, listeners => []
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
-elvis([{elvis_style, god_modules, disable}]).
|
||||||
|
-elvis([{elvis_style, no_nested_try_catch, disable}]).
|
||||||
|
|
||||||
|
|
||||||
-define(DEFAULT_CALL_TIMEOUT, 15000).
|
-define(DEFAULT_CALL_TIMEOUT, 15000).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
stopped_at :: integer() | undefined
|
stopped_at :: integer() | undefined
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
-elvis([{elvis_style, invalid_dynamic_call, disable}]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% APIs
|
%% APIs
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -312,13 +314,13 @@ do_update_one_by_one(NCfg, State = #state{
|
||||||
OAuths = authns(GwName, OCfg),
|
OAuths = authns(GwName, OCfg),
|
||||||
NAuths = authns(GwName, NCfg),
|
NAuths = authns(GwName, NCfg),
|
||||||
|
|
||||||
if
|
case {Status, NEnable} of
|
||||||
Status == stopped, NEnable == true ->
|
{stopped, true} ->
|
||||||
NState = State#state{config = NCfg},
|
NState = State#state{config = NCfg},
|
||||||
cb_gateway_load(NState);
|
cb_gateway_load(NState);
|
||||||
Status == stopped, NEnable == false ->
|
{stopped, false} ->
|
||||||
{ok, State#state{config = NCfg}};
|
{ok, State#state{config = NCfg}};
|
||||||
Status == running, NEnable == true ->
|
{running, true} ->
|
||||||
NState = case NAuths == OAuths of
|
NState = case NAuths == OAuths of
|
||||||
true -> State;
|
true -> State;
|
||||||
false ->
|
false ->
|
||||||
|
@ -329,12 +331,12 @@ do_update_one_by_one(NCfg, State = #state{
|
||||||
end,
|
end,
|
||||||
%% XXX: minimum impact update ???
|
%% XXX: minimum impact update ???
|
||||||
cb_gateway_update(NCfg, NState);
|
cb_gateway_update(NCfg, NState);
|
||||||
Status == running, NEnable == false ->
|
{running, false} ->
|
||||||
case cb_gateway_unload(State) of
|
case cb_gateway_unload(State) of
|
||||||
{ok, NState} -> {ok, NState#state{config = NCfg}};
|
{ok, NState} -> {ok, NState#state{config = NCfg}};
|
||||||
{error, Reason} -> {error, Reason}
|
{error, Reason} -> {error, Reason}
|
||||||
end;
|
end;
|
||||||
true ->
|
_ ->
|
||||||
throw(nomatch)
|
throw(nomatch)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@
|
||||||
-define(DEFAULT_OOM_POLICY, #{max_heap_size => 4194304,
|
-define(DEFAULT_OOM_POLICY, #{max_heap_size => 4194304,
|
||||||
message_queue_len => 32000}).
|
message_queue_len => 32000}).
|
||||||
|
|
||||||
|
-elvis([{elvis_style, god_modules, disable}]).
|
||||||
|
|
||||||
-spec childspec(supervisor:worker(), Mod :: atom())
|
-spec childspec(supervisor:worker(), Mod :: atom())
|
||||||
-> supervisor:child_spec().
|
-> supervisor:child_spec().
|
||||||
childspec(Type, Mod) ->
|
childspec(Type, Mod) ->
|
||||||
|
|
Loading…
Reference in New Issue