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