Просмотр исходного кода

chore(formatting): Fix formatting of modules, authz and authn

ieQu1 3 лет назад
Родитель
Сommit
8df76da9ac

+ 2 - 1
apps/emqx/src/emqx_schema.erl

@@ -1294,7 +1294,8 @@ fields("broker_perf") ->
                         "Change this parameter only when there are many wildcard topics.<br/>\n"
                         "NOTE: when changing from/to `global` lock, it requires all\n"
                         "nodes in the cluster to be stopped before the change.\n\n"
-                        " - `key`: mnesia transactional updates with per-key locks. Recommended for a single-node setup.\n"
+                        " - `key`: mnesia transactional updates with per-key locks. "
+                        "Recommended for a single-node setup.\n"
                         " - `tab`: mnesia transactional updates with table lock. Recommended for a cluster setup.\n"
                         " - `global`: updates are protected with a global lock. Recommended for large clusters."
                 }

+ 2 - 1
apps/emqx_authn/src/simple_authn/emqx_authn_http.erl

@@ -78,7 +78,8 @@ common_fields() ->
         {mechanism, emqx_authn_schema:mechanism('password_based')},
         {backend, emqx_authn_schema:backend(http)},
         {url, fun url/1},
-        {body, hoconsc:mk(map([{fuzzy, term(), binary()}]), #{desc => "Body of the HTTP request."})},
+        {body,
+            hoconsc:mk(map([{fuzzy, term(), binary()}]), #{desc => "Body of the HTTP request."})},
         {request_timeout, fun request_timeout/1}
     ] ++ emqx_authn_schema:common_fields() ++
         maps:to_list(

+ 58 - 46
apps/emqx_authz/src/emqx_authz_schema.erl

@@ -27,12 +27,13 @@
 -type action() :: publish | subscribe | all.
 -type permission() :: allow | deny.
 
--export([ namespace/0
-        , roots/0
-        , fields/1
-        , validations/0
-        , desc/1
-        ]).
+-export([
+    namespace/0,
+    roots/0,
+    fields/1,
+    validations/0,
+    desc/1
+]).
 
 -export([
     headers_no_content_type/1,
@@ -94,38 +95,45 @@ fields("authorization") ->
         }}
     ];
 fields(file) ->
-    [ {type, #{type => file, desc => "Backend type."}}
-    , {enable, #{type => boolean(),
-                 default => true,
-                 desc => "Enable this backend."
-                }}
-    , {path, #{type => string(),
-               required => true,
-               desc => "
-Path to the file which contains the ACL rules.<br>
-If the file provisioned before starting EMQX node,
-it can be placed anywhere as long as EMQX has read access to it.
-
-In case the rule-set is created from EMQX dashboard or management API,
-the file will be placed in `authz` subdirectory inside EMQX's `data_dir`,
-and the new rules will override all rules from the old config file.
-"
-              }}
+    [
+        {type, #{type => file, desc => "Backend type."}},
+        {enable, #{
+            type => boolean(),
+            default => true,
+            desc => "Enable this backend."
+        }},
+        {path, #{
+            type => string(),
+            required => true,
+            desc =>
+                "\n"
+                "Path to the file which contains the ACL rules.<br>\n"
+                "If the file provisioned before starting EMQX node,\n"
+                "it can be placed anywhere as long as EMQX has read access to it.\n"
+                "\n"
+                "In case the rule-set is created from EMQX dashboard or management API,\n"
+                "the file will be placed in `authz` subdirectory inside EMQX's `data_dir`,\n"
+                "and the new rules will override all rules from the old config file.\n"
+        }}
     ];
 fields(http_get) ->
-    [ {method, #{type => get, default => get, desc => "HTTP method."}}
-    , {headers, fun headers_no_content_type/1}
+    [
+        {method, #{type => get, default => get, desc => "HTTP method."}},
+        {headers, fun headers_no_content_type/1}
     ] ++ http_common_fields();
 fields(http_post) ->
-    [ {method, #{type => post, default => post, desc => "HTTP method."}}
-    , {headers, fun headers/1}
+    [
+        {method, #{type => post, default => post, desc => "HTTP method."}},
+        {headers, fun headers/1}
     ] ++ http_common_fields();
 fields(mnesia) ->
-    [ {type, #{type => 'built_in_database', desc => "Backend type."}}
-    , {enable, #{type => boolean(),
-                 default => true,
-                 desc => "Enable this backend."
-                }}
+    [
+        {type, #{type => 'built_in_database', desc => "Backend type."}},
+        {enable, #{
+            type => boolean(),
+            default => true,
+            desc => "Enable this backend."
+        }}
     ];
 fields(mongo_single) ->
     mongo_common_fields() ++ emqx_connector_mongo:fields(single);
@@ -137,11 +145,14 @@ fields(mysql) ->
     connector_fields(mysql) ++
         [{query, query()}];
 fields(postgresql) ->
-    [ {query, query()}
-    , {type, #{type => postgresql, desc => "Backend type."}}
-    , {enable, #{type => boolean(),
-                 desc => "Enable this backend.",
-                 default => true}}
+    [
+        {query, query()},
+        {type, #{type => postgresql, desc => "Backend type."}},
+        {enable, #{
+            type => boolean(),
+            desc => "Enable this backend.",
+            default => true
+        }}
     ] ++ emqx_connector_pgsql:fields(config);
 fields(redis_single) ->
     connector_fields(redis, single) ++
@@ -321,15 +332,16 @@ union_array(Item) when is_list(Item) ->
     hoconsc:array(hoconsc:union(Item)).
 
 query() ->
-    #{type => binary(),
-      desc => "Database query used to retrieve authorization data.",
-      validator => fun(S) ->
-                         case size(S) > 0 of
-                             true -> ok;
-                             _ -> {error, "Request query"}
-                         end
-                       end
-     }.
+    #{
+        type => binary(),
+        desc => "Database query used to retrieve authorization data.",
+        validator => fun(S) ->
+            case size(S) > 0 of
+                true -> ok;
+                _ -> {error, "Request query"}
+            end
+        end
+    }.
 
 connector_fields(DB) ->
     connector_fields(DB, config).

+ 2 - 1
apps/emqx_modules/src/emqx_modules_schema.erl

@@ -42,7 +42,8 @@ fields("telemetry") ->
 fields("delayed") ->
     [
         {enable, hoconsc:mk(boolean(), #{default => false, desc => "Enable `delayed` module."})},
-        {max_delayed_messages, sc(integer(), #{desc => "Maximum number of delayed messages (0 is no limit)."})}
+        {max_delayed_messages,
+            sc(integer(), #{desc => "Maximum number of delayed messages (0 is no limit)."})}
     ];
 fields("rewrite") ->
     [

+ 8 - 4
apps/emqx_retainer/src/emqx_retainer_schema.erl

@@ -26,7 +26,8 @@ fields("retainer") ->
     , {stop_publish_clear_msg, sc(boolean(),
                                   "When the retained flag of the `PUBLISH` message is set and Payload is empty, "
                                   "whether to continue to publish the message.<br/>"
-                                  "See: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718038",
+                                  "See: "
+                                  "http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718038",
                                   false)}
     , {backend, backend_config()}
     ];
@@ -52,9 +53,12 @@ fields(flow_control) ->
                                 0)}
     , {batch_deliver_limiter, sc(emqx_limiter_schema:bucket_name(),
                                  "The rate limiter name for retained messages' delivery.<br/>"
-                                 "Limiter helps to avoid delivering too many messages to the client at once, which may cause the client "
-                                 "to block or crash, or drop messages due to exceeding the size of the message queue.<br/>"
-                                 "The names of the available rate limiters are taken from the existing rate limiters under `limiter.batch`.<br/>"
+                                 "Limiter helps to avoid delivering too many messages to the client at once, "
+                                 "which may cause the client "
+                                 "to block or crash, or drop messages due to exceeding the size of the message"
+                                 " queue.<br/>"
+                                 "The names of the available rate limiters are taken from the existing rate "
+                                 "limiters under `limiter.batch`.<br/>"
                                  "If this field is empty, limiter is not used.",
                                  undefined)}
     ].