fix: format the code to remove extra spaces

This commit is contained in:
Shawn 2022-02-09 14:47:04 +08:00
parent e6997dc1ce
commit 8207090419
34 changed files with 122 additions and 124 deletions

View File

@ -46,7 +46,7 @@
-define(SYSTOP, <<"$SYS/">>). -define(SYSTOP, <<"$SYS/">>).
%% Queue topic %% Queue topic
-define(QUEUE, <<"$queue/">>). -define(QUEUE, <<"$queue/">>).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% alarms %% alarms

View File

@ -87,7 +87,7 @@
-define(OVERLOAD_MIN_ALLOC, 0.3). %% minimum coefficient for overloaded limiter -define(OVERLOAD_MIN_ALLOC, 0.3). %% minimum coefficient for overloaded limiter
-export_type([index/0]). -export_type([index/0]).
-import(emqx_limiter_decimal, [add/2, sub/2, mul/2, put_to_counter/3]). -import(emqx_limiter_decimal, [add/2, sub/2, mul/2, put_to_counter/3]).
-elvis([{elvis_style, no_if_expression, disable}]). -elvis([{elvis_style, no_if_expression, disable}]).

View File

@ -177,7 +177,7 @@ info(packet_id, #mqtt_packet_puback{packet_id = PacketId}) ->
PacketId; PacketId;
info(reason_code, #mqtt_packet_puback{reason_code = RC}) -> info(reason_code, #mqtt_packet_puback{reason_code = RC}) ->
RC; RC;
info(properties, #mqtt_packet_puback{properties = Props}) -> info(properties, #mqtt_packet_puback{properties = Props}) ->
Props; Props;
info(packet_id, #mqtt_packet_subscribe{packet_id = PacketId}) -> info(packet_id, #mqtt_packet_subscribe{packet_id = PacketId}) ->

View File

@ -78,7 +78,7 @@ is_queue({queue, R, F, L}) when is_list(R), is_list(F), is_integer(L) ->
true; true;
is_queue({pqueue, Queues}) when is_list(Queues) -> is_queue({pqueue, Queues}) when is_list(Queues) ->
lists:all(fun ({infinity, Q}) -> is_queue(Q); lists:all(fun ({infinity, Q}) -> is_queue(Q);
({P, Q}) -> is_integer(P) andalso is_queue(Q) ({P, Q}) -> is_integer(P) andalso is_queue(Q)
end, Queues); end, Queues);
is_queue(_) -> is_queue(_) ->
false. false.
@ -268,9 +268,9 @@ highest({queue, [], [], 0}) -> empty;
highest({queue, _, _, _}) -> 0; highest({queue, _, _, _}) -> 0;
highest({pqueue, [{P, _} | _]}) -> maybe_negate_priority(P). highest({pqueue, [{P, _} | _]}) -> maybe_negate_priority(P).
r2f([], 0) -> {queue, [], [], 0}; r2f([], 0) -> {queue, [], [], 0};
r2f([_] = R, 1) -> {queue, [], R, 1}; r2f([_] = R, 1) -> {queue, [], R, 1};
r2f([X,Y], 2) -> {queue, [X], [Y], 2}; r2f([X,Y], 2) -> {queue, [X], [Y], 2};
r2f([X,Y|R], L) -> {queue, [X,Y], lists:reverse(R, []), L}. r2f([X,Y|R], L) -> {queue, [X,Y], lists:reverse(R, []), L}.
maybe_negate_priority(infinity) -> infinity; maybe_negate_priority(infinity) -> infinity;

View File

@ -697,7 +697,7 @@ resume(ClientInfo = #{clientid := ClientId}, Session = #session{subscriptions =
-spec(replay(emqx_types:clientinfo(), session()) -> {ok, replies(), session()}). -spec(replay(emqx_types:clientinfo(), session()) -> {ok, replies(), session()}).
replay(ClientInfo, Session = #session{inflight = Inflight}) -> replay(ClientInfo, Session = #session{inflight = Inflight}) ->
Pubs = lists:map(fun({PacketId, {Pubrel, _Ts}}) when is_record(Pubrel, pubrel_await) -> Pubs = lists:map(fun({PacketId, {Pubrel, _Ts}}) when is_record(Pubrel, pubrel_await) ->
{pubrel, PacketId}; {pubrel, PacketId};
({PacketId, {Msg, _Ts}}) -> ({PacketId, {Msg, _Ts}}) ->
{PacketId, emqx_message:set_flag(dup, true, Msg)} {PacketId, emqx_message:set_flag(dup, true, Msg)}

View File

@ -110,9 +110,9 @@ sys_heatbeat_interval() ->
%% @doc Get sys info %% @doc Get sys info
-spec(info() -> list(tuple())). -spec(info() -> list(tuple())).
info() -> info() ->
[{version, version()}, [{version, version()},
{sysdescr, sysdescr()}, {sysdescr, sysdescr()},
{uptime, uptime()}, {uptime, uptime()},
{datetime, datetime()}]. {datetime, datetime()}].
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------

View File

@ -166,8 +166,8 @@ schedulers() ->
erlang:system_info(schedulers). erlang:system_info(schedulers).
loads() -> loads() ->
[{load1, ftos(avg1()/256)}, [{load1, ftos(avg1()/256)},
{load5, ftos(avg5()/256)}, {load5, ftos(avg5()/256)},
{load15, ftos(avg15()/256)} {load15, ftos(avg15()/256)}
]. ].

View File

@ -88,7 +88,7 @@ roots() -> [?CONF_NS].
fields(?CONF_NS) -> fields(?CONF_NS) ->
[ {mechanism, emqx_authn_schema:mechanism('scram')} [ {mechanism, emqx_authn_schema:mechanism('scram')}
, {backend, emqx_authn_schema:backend('built-in-database')} , {backend, emqx_authn_schema:backend('built-in-database')}
, {algorithm, fun algorithm/1} , {algorithm, fun algorithm/1}
, {iteration_count, fun iteration_count/1} , {iteration_count, fun iteration_count/1}
] ++ emqx_authn_schema:common_fields(). ] ++ emqx_authn_schema:common_fields().

View File

@ -50,22 +50,20 @@ roots() ->
]. ].
fields(get) -> fields(get) ->
[ {method, #{type => get, [ {method, #{type => get, default => post}}
default => post}} , {headers, fun headers_no_content_type/1}
, {headers, fun headers_no_content_type/1}
] ++ common_fields(); ] ++ common_fields();
fields(post) -> fields(post) ->
[ {method, #{type => post, [ {method, #{type => post, default => post}}
default => post}} , {headers, fun headers/1}
, {headers, fun headers/1}
] ++ common_fields(). ] ++ common_fields().
common_fields() -> common_fields() ->
[ {mechanism, emqx_authn_schema:mechanism('password-based')} [ {mechanism, emqx_authn_schema:mechanism('password-based')}
, {backend, emqx_authn_schema:backend(http)} , {backend, emqx_authn_schema:backend(http)}
, {url, fun url/1} , {url, fun url/1}
, {body, fun body/1} , {body, fun body/1}
, {request_timeout, fun request_timeout/1} , {request_timeout, fun request_timeout/1}
] ++ emqx_authn_schema:common_fields() ] ++ emqx_authn_schema:common_fields()
++ maps:to_list(maps:without([ base_url ++ maps:to_list(maps:without([ base_url

View File

@ -48,35 +48,34 @@ roots() ->
]. ].
fields('hmac-based') -> fields('hmac-based') ->
[ {use_jwks, {enum, [false]}} [ {use_jwks, {enum, [false]}}
, {algorithm, {enum, ['hmac-based']}} , {algorithm, {enum, ['hmac-based']}}
, {secret, fun secret/1} , {secret, fun secret/1}
, {secret_base64_encoded, fun secret_base64_encoded/1} , {secret_base64_encoded, fun secret_base64_encoded/1}
] ++ common_fields(); ] ++ common_fields();
fields('public-key') -> fields('public-key') ->
[ {use_jwks, {enum, [false]}} [ {use_jwks, {enum, [false]}}
, {algorithm, {enum, ['public-key']}} , {algorithm, {enum, ['public-key']}}
, {certificate, fun certificate/1} , {certificate, fun certificate/1}
] ++ common_fields(); ] ++ common_fields();
fields('jwks') -> fields('jwks') ->
[ {use_jwks, {enum, [true]}} [ {use_jwks, {enum, [true]}}
, {endpoint, fun endpoint/1} , {endpoint, fun endpoint/1}
, {refresh_interval, fun refresh_interval/1} , {refresh_interval, fun refresh_interval/1}
, {ssl, #{type => hoconsc:union( , {ssl, #{type => hoconsc:union([ hoconsc:ref(?MODULE, ssl_enable)
[ hoconsc:ref(?MODULE, ssl_enable) , hoconsc:ref(?MODULE, ssl_disable)
, hoconsc:ref(?MODULE, ssl_disable) ]),
]), default => #{<<"enable">> => false}}}
default => #{<<"enable">> => false}}}
] ++ common_fields(); ] ++ common_fields();
fields(ssl_enable) -> fields(ssl_enable) ->
[ {enable, #{type => true}} [ {enable, #{type => true}}
, {cacertfile, fun cacertfile/1} , {cacertfile, fun cacertfile/1}
, {certfile, fun certfile/1} , {certfile, fun certfile/1}
, {keyfile, fun keyfile/1} , {keyfile, fun keyfile/1}
, {verify, fun verify/1} , {verify, fun verify/1}
, {server_name_indication, fun server_name_indication/1} , {server_name_indication, fun server_name_indication/1}
]; ];
@ -85,7 +84,7 @@ fields(ssl_disable) ->
common_fields() -> common_fields() ->
[ {mechanism, emqx_authn_schema:mechanism('jwt')} [ {mechanism, emqx_authn_schema:mechanism('jwt')}
, {verify_claims, fun verify_claims/1} , {verify_claims, fun verify_claims/1}
] ++ emqx_authn_schema:common_fields(). ] ++ emqx_authn_schema:common_fields().
secret(type) -> binary(); secret(type) -> binary();

View File

@ -90,7 +90,7 @@ roots() -> [?CONF_NS].
fields(?CONF_NS) -> fields(?CONF_NS) ->
[ {mechanism, emqx_authn_schema:mechanism('password-based')} [ {mechanism, emqx_authn_schema:mechanism('password-based')}
, {backend, emqx_authn_schema:backend('built-in-database')} , {backend, emqx_authn_schema:backend('built-in-database')}
, {user_id_type, fun user_id_type/1} , {user_id_type, fun user_id_type/1}
, {password_hash_algorithm, fun emqx_authn_password_hashing:type_rw/1} , {password_hash_algorithm, fun emqx_authn_password_hashing:type_rw/1}
] ++ emqx_authn_schema:common_fields(). ] ++ emqx_authn_schema:common_fields().

View File

@ -58,11 +58,11 @@ fields('sharded-cluster') ->
common_fields() -> common_fields() ->
[ {mechanism, emqx_authn_schema:mechanism('password-based')} [ {mechanism, emqx_authn_schema:mechanism('password-based')}
, {backend, emqx_authn_schema:backend(mongodb)} , {backend, emqx_authn_schema:backend(mongodb)}
, {collection, fun collection/1} , {collection, fun collection/1}
, {selector, fun selector/1} , {selector, fun selector/1}
, {password_hash_field, fun password_hash_field/1} , {password_hash_field, fun password_hash_field/1}
, {salt_field, fun salt_field/1} , {salt_field, fun salt_field/1}
, {is_superuser_field, fun is_superuser_field/1} , {is_superuser_field, fun is_superuser_field/1}
, {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1} , {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1}
] ++ emqx_authn_schema:common_fields(). ] ++ emqx_authn_schema:common_fields().

View File

@ -47,8 +47,8 @@ fields(?CONF_NS) ->
[ {mechanism, emqx_authn_schema:mechanism('password-based')} [ {mechanism, emqx_authn_schema:mechanism('password-based')}
, {backend, emqx_authn_schema:backend(mysql)} , {backend, emqx_authn_schema:backend(mysql)}
, {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1} , {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1}
, {query, fun query/1} , {query, fun query/1}
, {query_timeout, fun query_timeout/1} , {query_timeout, fun query_timeout/1}
] ++ emqx_authn_schema:common_fields() ] ++ emqx_authn_schema:common_fields()
++ emqx_connector_schema_lib:relational_db_fields() ++ emqx_connector_schema_lib:relational_db_fields()
++ emqx_connector_schema_lib:ssl_fields(). ++ emqx_connector_schema_lib:ssl_fields().

View File

@ -53,7 +53,7 @@ fields(?CONF_NS) ->
[ {mechanism, emqx_authn_schema:mechanism('password-based')} [ {mechanism, emqx_authn_schema:mechanism('password-based')}
, {backend, emqx_authn_schema:backend(postgresql)} , {backend, emqx_authn_schema:backend(postgresql)}
, {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1} , {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1}
, {query, fun query/1} , {query, fun query/1}
] ++ emqx_authn_schema:common_fields() ] ++ emqx_authn_schema:common_fields()
++ emqx_connector_schema_lib:relational_db_fields() ++ emqx_connector_schema_lib:relational_db_fields()
++ emqx_connector_schema_lib:ssl_fields(). ++ emqx_connector_schema_lib:ssl_fields().

View File

@ -58,7 +58,7 @@ fields(sentinel) ->
common_fields() -> common_fields() ->
[ {mechanism, emqx_authn_schema:mechanism('password-based')} [ {mechanism, emqx_authn_schema:mechanism('password-based')}
, {backend, emqx_authn_schema:backend(redis)} , {backend, emqx_authn_schema:backend(redis)}
, {cmd, fun cmd/1} , {cmd, fun cmd/1}
, {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1} , {password_hash_algorithm, fun emqx_authn_password_hashing:type_ro/1}
] ++ emqx_authn_schema:common_fields(). ] ++ emqx_authn_schema:common_fields().

View File

@ -222,24 +222,36 @@ schema("/authorization/sources/built-in-database/purge-all") ->
}. }.
fields(rule_item) -> fields(rule_item) ->
[ {topic, hoconsc:mk( string() [ {topic, hoconsc:mk(string(),
, #{ required => true #{ required => true
, desc => <<"Rule on specific topic">> , desc => <<"Rule on specific topic">>
, example => <<"test/topic/1">>})} , example => <<"test/topic/1">>
, {permission, hoconsc:mk( hoconsc:enum([allow, deny]) })}
, #{desc => <<"Permission">>, required => true, example => allow})} , {permission, hoconsc:mk(hoconsc:enum([allow, deny]),
, {action, hoconsc:mk( hoconsc:enum([publish, subscribe, all]) #{ desc => <<"Permission">>
, #{ required => true, example => publish , required => true
, desc => <<"Authorized action">> })} ]; , example => allow
})}
, {action, hoconsc:mk(hoconsc:enum([publish, subscribe, all]),
#{ required => true
, example => publish
, desc => <<"Authorized action">>
})}
];
fields(clientid) -> fields(clientid) ->
[ {clientid, hoconsc:mk( binary() [ {clientid, hoconsc:mk(binary(),
, #{ in => path, required => true #{ in => path
, desc => <<"ClientID">>, example => <<"client1">>})} , required => true
, desc => <<"ClientID">>
, example => <<"client1">>
})}
]; ];
fields(username) -> fields(username) ->
[ {username, hoconsc:mk( binary() [ {username, hoconsc:mk(binary(),
, #{ in => path, required => true #{ in => path
, desc => <<"Username">>, example => <<"user1">>})} , required => true
, desc => <<"Username">>
, example => <<"user1">>})}
]; ];
fields(rules_for_username) -> fields(rules_for_username) ->
[ {rules, hoconsc:mk(hoconsc:array(hoconsc:ref(rule_item)), #{})} [ {rules, hoconsc:mk(hoconsc:array(hoconsc:ref(rule_item)), #{})}
@ -400,7 +412,7 @@ rules_example({ExampleName, ExampleType}) ->
case ExampleName of case ExampleName of
username -> {<<"Username">>, ?USERNAME_RULES_EXAMPLE}; username -> {<<"Username">>, ?USERNAME_RULES_EXAMPLE};
clientid -> {<<"ClientID">>, ?CLIENTID_RULES_EXAMPLE}; clientid -> {<<"ClientID">>, ?CLIENTID_RULES_EXAMPLE};
all -> {<<"All">>, ?ALL_RULES_EXAMPLE} all -> {<<"All">>, ?ALL_RULES_EXAMPLE}
end, end,
Value = Value =
case ExampleType of case ExampleType of

View File

@ -31,7 +31,7 @@
, compile/1 , compile/1
]). ]).
-type(ipaddress() :: {ipaddr, esockd_cidr:cidr_string()} | -type(ipaddress() :: {ipaddr, esockd_cidr:cidr_string()} |
{ipaddrs, list(esockd_cidr:cidr_string())}). {ipaddrs, list(esockd_cidr:cidr_string())}).
-type(username() :: {username, binary()}). -type(username() :: {username, binary()}).

View File

@ -106,15 +106,15 @@ and the new rules will override all rules from the old config file.
}} }}
]; ];
fields(http_get) -> fields(http_get) ->
[ {method, #{type => get, default => post}} [ {method, #{type => get, default => post}}
, {headers, fun headers_no_content_type/1} , {headers, fun headers_no_content_type/1}
] ++ http_common_fields(); ] ++ http_common_fields();
fields(http_post) -> fields(http_post) ->
[ {method, #{type => post, default => post}} [ {method, #{type => post, default => post}}
, {headers, fun headers/1} , {headers, fun headers/1}
] ++ http_common_fields(); ] ++ http_common_fields();
fields(mnesia) -> fields(mnesia) ->
[ {type, #{type => 'built-in-database'}} [ {type, #{type => 'built-in-database'}}
, {enable, #{type => boolean(), , {enable, #{type => boolean(),
default => true}} default => true}}
]; ];
@ -144,11 +144,11 @@ fields(redis_cluster) ->
[ {cmd, query()} ]. [ {cmd, query()} ].
http_common_fields() -> http_common_fields() ->
[ {type, #{type => http}} [ {type, #{type => http}}
, {enable, #{type => boolean(), default => true}} , {enable, #{type => boolean(), default => true}}
, {url, fun url/1} , {url, fun url/1}
, {request_timeout, mk_duration("request timeout", #{default => "30s"})} , {request_timeout, mk_duration("request timeout", #{default => "30s"})}
, {body, #{type => map(), nullable => true}} , {body, #{type => map(), nullable => true}}
] ++ proplists:delete(base_url, emqx_connector_http:fields(config)). ] ++ proplists:delete(base_url, emqx_connector_http:fields(config)).
mongo_common_fields() -> mongo_common_fields() ->

View File

@ -32,20 +32,9 @@
start_link() -> start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []). supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%% sup_flags() = #{strategy => strategy(), % optional
%% intensity => non_neg_integer(), % optional
%% period => pos_integer()} % optional
%% child_spec() = #{id => child_id(), % mandatory
%% start => mfargs(), % mandatory
%% restart => restart(), % optional
%% shutdown => shutdown(), % optional
%% type => worker(), % optional
%% modules => modules()} % optional
init([]) -> init([]) ->
SupFlags = #{strategy => one_for_all, SupFlags = #{strategy => one_for_all,
intensity => 0, intensity => 0,
period => 1}, period => 1},
ChildSpecs = [], ChildSpecs = [],
{ok, {SupFlags, ChildSpecs}}. {ok, {SupFlags, ChildSpecs}}.
%% internal functions

View File

@ -36,10 +36,10 @@ fields("topic") ->
[ {topic, sc(binary(), #{})} [ {topic, sc(binary(), #{})}
, {qos, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]), , {qos, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]),
#{default => 0})} #{default => 0})}
, {rh, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]), , {rh, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]),
#{default => 0})} #{default => 0})}
, {rap, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1)]), #{default => 0})} , {rap, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1)]), #{default => 0})}
, {nl, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1)]), #{default => 0})} , {nl, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1)]), #{default => 0})}
]. ].
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------

View File

@ -33,7 +33,7 @@ admins(["status"]) -> status();
admins(["skip"]) -> admins(["skip"]) ->
status(), status(),
Nodes = mria_mnesia:running_nodes(), Nodes = mria_mnesia:running_nodes(),
lists:foreach(fun emqx_cluster_rpc:skip_failed_commit/1, Nodes), lists:foreach(fun emqx_cluster_rpc:skip_failed_commit/1, Nodes),
status(); status();
admins(["skip", Node0]) -> admins(["skip", Node0]) ->
@ -70,7 +70,7 @@ admins(["fast_forward", Node0, ToTnxId]) ->
admins(_) -> admins(_) ->
emqx_ctl:usage( emqx_ctl:usage(
[ [
{"cluster_call status", "status"}, {"cluster_call status", "status"},
{"cluster_call skip [node]", "increase one commit on specific node"}, {"cluster_call skip [node]", "increase one commit on specific node"},
{"cluster_call tnxid <TnxId>", "get detailed about TnxId"}, {"cluster_call tnxid <TnxId>", "get detailed about TnxId"},
{"cluster_call fast_forward [node] [tnx_id]", "fast forwards to tnx_id" } {"cluster_call fast_forward [node] [tnx_id]", "fast forwards to tnx_id" }

View File

@ -263,8 +263,8 @@ fields("node") ->
})} })}
, {"global_gc_interval", , {"global_gc_interval",
sc(emqx_schema:duration(), sc(emqx_schema:duration(),
#{ mapping => "emqx_machine.global_gc_interval" #{ mapping => "emqx_machine.global_gc_interval"
, default => "15m" , default => "15m"
})} })}
, {"crash_dump_file", , {"crash_dump_file",
sc(file(), sc(file(),
@ -386,15 +386,15 @@ fields("cluster_call") ->
})} })}
, {"max_history", , {"max_history",
sc(range(1, 500), sc(range(1, 500),
#{ desc => "Retain the maximum number of completed transactions (for queries)." #{ desc => "Retain the maximum number of completed transactions (for queries)."
, default => 100 , default => 100
})} })}
, {"cleanup_interval", , {"cleanup_interval",
sc(emqx_schema:duration(), sc(emqx_schema:duration(),
#{ desc => #{ desc =>
"Time interval to clear completed but stale transactions. "Time interval to clear completed but stale transactions.
Ensure that the number of completed transactions is less than the max_history." Ensure that the number of completed transactions is less than the max_history."
, default => "5m" , default => "5m"
})} })}
]; ];

View File

@ -63,7 +63,7 @@ on_gateway_load(_Gateway = #{name := GwName,
case start_listeners( case start_listeners(
Listeners, GwName, Ctx, ModCfg) of Listeners, GwName, Ctx, ModCfg) of
{ok, ListenerPids} -> {ok, ListenerPids} ->
{ok, ListenerPids, #{ctx => Ctx}}; {ok, ListenerPids, #{ctx => Ctx}};
{error, {Reason, Listener}} -> {error, {Reason, Listener}} ->
throw({badconf, #{ key => listeners throw({badconf, #{ key => listeners
, vallue => Listener , vallue => Listener

View File

@ -639,7 +639,7 @@ fields(subscription) ->
mk(integer(), mk(integer(),
#{ desc => <<"QoS level, enum: 0, 1, 2">>})} #{ desc => <<"QoS level, enum: 0, 1, 2">>})}
, {nl, , {nl,
mk(integer(), %% FIXME: why not boolean? mk(integer(), %% FIXME: why not boolean?
#{ desc => <<"No Local option, enum: 0, 1">>})} #{ desc => <<"No Local option, enum: 0, 1">>})}
, {rap, , {rap,
mk(integer(), mk(integer(),

View File

@ -87,7 +87,7 @@
-define(RECORD_SIZE(R), (erlang:map_size(R) - 1)). -define(RECORD_SIZE(R), (erlang:map_size(R) - 1)).
%% uplink and downlink topic configuration %% uplink and downlink topic configuration
-define(lwm2m_up_dm_topic, {<<"/v1/up/dm">>, 0}). -define(lwm2m_up_dm_topic, {<<"/v1/up/dm">>, 0}).
%% steal from emqx_session %% steal from emqx_session
-define(INFO_KEYS, [id, -define(INFO_KEYS, [id,

View File

@ -44,7 +44,7 @@ print_vsn() ->
start_autocluster() -> start_autocluster() ->
ekka:callback(stop, fun emqx_machine_boot:stop_apps/0), ekka:callback(stop, fun emqx_machine_boot:stop_apps/0),
ekka:callback(start, fun emqx_machine_boot:ensure_apps_started/0), ekka:callback(start, fun emqx_machine_boot:ensure_apps_started/0),
_ = ekka:autocluster(emqx), %% returns 'ok' or a pid or 'any()' as in spec _ = ekka:autocluster(emqx), %% returns 'ok' or a pid or 'any()' as in spec
ok. ok.

View File

@ -48,9 +48,9 @@ enable() ->
register_hook(Rules). register_hook(Rules).
disable() -> disable() ->
emqx_hooks:del('client.subscribe', {?MODULE, rewrite_subscribe}), emqx_hooks:del('client.subscribe', {?MODULE, rewrite_subscribe}),
emqx_hooks:del('client.unsubscribe', {?MODULE, rewrite_unsubscribe}), emqx_hooks:del('client.unsubscribe', {?MODULE, rewrite_unsubscribe}),
emqx_hooks:del('message.publish', {?MODULE, rewrite_publish}), emqx_hooks:del('message.publish', {?MODULE, rewrite_publish}),
ok. ok.
list() -> list() ->
@ -63,9 +63,9 @@ update(Rules0) ->
register_hook([]) -> disable(); register_hook([]) -> disable();
register_hook(Rules) -> register_hook(Rules) ->
{PubRules, SubRules, ErrRules} = compile(Rules), {PubRules, SubRules, ErrRules} = compile(Rules),
emqx_hooks:put('client.subscribe', {?MODULE, rewrite_subscribe, [SubRules]}), emqx_hooks:put('client.subscribe', {?MODULE, rewrite_subscribe, [SubRules]}),
emqx_hooks:put('client.unsubscribe', {?MODULE, rewrite_unsubscribe, [SubRules]}), emqx_hooks:put('client.unsubscribe', {?MODULE, rewrite_unsubscribe, [SubRules]}),
emqx_hooks:put('message.publish', {?MODULE, rewrite_publish, [PubRules]}), emqx_hooks:put('message.publish', {?MODULE, rewrite_publish, [PubRules]}),
case ErrRules of case ErrRules of
[] -> ok; [] -> ok;
_ -> _ ->

View File

@ -101,13 +101,13 @@ max_limit() ->
?MAX_TOPICS. ?MAX_TOPICS.
enable() -> enable() ->
emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []}), emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []}),
emqx_hooks:put('message.dropped', {?MODULE, on_message_dropped, []}), emqx_hooks:put('message.dropped', {?MODULE, on_message_dropped, []}),
emqx_hooks:put('message.delivered', {?MODULE, on_message_delivered, []}). emqx_hooks:put('message.delivered', {?MODULE, on_message_delivered, []}).
disable() -> disable() ->
emqx_hooks:del('message.publish', {?MODULE, on_message_publish}), emqx_hooks:del('message.publish', {?MODULE, on_message_publish}),
emqx_hooks:del('message.dropped', {?MODULE, on_message_dropped}), emqx_hooks:del('message.dropped', {?MODULE, on_message_dropped}),
emqx_hooks:del('message.delivered', {?MODULE, on_message_delivered}), emqx_hooks:del('message.delivered', {?MODULE, on_message_delivered}),
deregister_all(). deregister_all().

View File

@ -150,55 +150,55 @@ fields(metrics) ->
, mk( integer(), #{ desc => <<"Message dropped count">> , mk( integer(), #{ desc => <<"Message dropped count">>
, example => 0})}, , example => 0})},
{ 'messages.dropped.rate' { 'messages.dropped.rate'
, mk( number(), #{ desc => <<"Message dropped rate in 5s">> , mk( number(), #{ desc => <<"Message dropped rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.in.count' { 'messages.in.count'
, mk( integer(), #{ desc => <<"Message received count">> , mk( integer(), #{ desc => <<"Message received count">>
, example => 0})}, , example => 0})},
{ 'messages.in.rate' { 'messages.in.rate'
, mk( number(), #{ desc => <<"Message received rate in 5s">> , mk( number(), #{ desc => <<"Message received rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.out.count' { 'messages.out.count'
, mk( integer(), #{ desc => <<"Message sent count">> , mk( integer(), #{ desc => <<"Message sent count">>
, example => 0})}, , example => 0})},
{ 'messages.out.rate' { 'messages.out.rate'
, mk( number(), #{ desc => <<"Message sent rate in 5s">> , mk( number(), #{ desc => <<"Message sent rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.qos0.in.count' { 'messages.qos0.in.count'
, mk( integer(), #{ desc => <<"Message with QoS 0 received count">> , mk( integer(), #{ desc => <<"Message with QoS 0 received count">>
, example => 0})}, , example => 0})},
{ 'messages.qos0.in.rate' { 'messages.qos0.in.rate'
, mk( number(), #{ desc => <<"Message with QoS 0 received rate in 5s">> , mk( number(), #{ desc => <<"Message with QoS 0 received rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.qos0.out.count' { 'messages.qos0.out.count'
, mk( integer(), #{ desc => <<"Message with QoS 0 sent count">> , mk( integer(), #{ desc => <<"Message with QoS 0 sent count">>
, example => 0})}, , example => 0})},
{ 'messages.qos0.out.rate' { 'messages.qos0.out.rate'
, mk( number(), #{ desc => <<"Message with QoS 0 sent rate in 5s">> , mk( number(), #{ desc => <<"Message with QoS 0 sent rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.qos1.in.count' { 'messages.qos1.in.count'
, mk( integer(), #{ desc => <<"Message with QoS 1 received count">> , mk( integer(), #{ desc => <<"Message with QoS 1 received count">>
, example => 0})}, , example => 0})},
{ 'messages.qos1.in.rate' { 'messages.qos1.in.rate'
, mk( number(), #{ desc => <<"Message with QoS 1 received rate in 5s">> , mk( number(), #{ desc => <<"Message with QoS 1 received rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.qos1.out.count' { 'messages.qos1.out.count'
, mk( integer(), #{ desc => <<"Message with QoS 1 sent count">> , mk( integer(), #{ desc => <<"Message with QoS 1 sent count">>
, example => 0})}, , example => 0})},
{ 'messages.qos1.out.rate' { 'messages.qos1.out.rate'
, mk( number(), #{ desc => <<"Message with QoS 1 sent rate in 5s">> , mk( number(), #{ desc => <<"Message with QoS 1 sent rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.qos2.in.count' { 'messages.qos2.in.count'
, mk( integer(), #{ desc => <<"Message with QoS 2 sent count">> , mk( integer(), #{ desc => <<"Message with QoS 2 sent count">>
, example => 0})}, , example => 0})},
{ 'messages.qos2.in.rate' { 'messages.qos2.in.rate'
, mk( number(), #{ desc => <<"Message with QoS 2 received rate in 5s">> , mk( number(), #{ desc => <<"Message with QoS 2 received rate in 5s">>
, example => 0})}, , example => 0})},
{ 'messages.qos2.out.count' { 'messages.qos2.out.count'
, mk( integer(), #{ desc => <<"Message with QoS 2 sent count">> , mk( integer(), #{ desc => <<"Message with QoS 2 sent count">>
, example => 0})}, , example => 0})},
{ 'messages.qos2.out.rate' { 'messages.qos2.out.rate'
, mk( number(), #{ desc => <<"Message with QoS 2 sent rate in 5s">> , mk( number(), #{ desc => <<"Message with QoS 2 sent rate in 5s">>
, example => 0})} , example => 0})}
]. ].

View File

@ -202,7 +202,7 @@ collect_metrics(Name, Metrics) ->
emqx_collect(Name, Metrics). emqx_collect(Name, Metrics).
add_collect_family(Name, Data, Callback, Type) -> add_collect_family(Name, Data, Callback, Type) ->
Callback(create_schema(Name, <<"">>, Data, Type)). Callback(create_schema(Name, <<"">>, Data, Type)).
create_schema(Name, Help, Data, Type) -> create_schema(Name, Help, Data, Type) ->
create_mf(Name, Help, Type, ?MODULE, Data). create_mf(Name, Help, Type, ?MODULE, Data).

View File

@ -42,9 +42,9 @@ to which is configurable by the <code>init_file</code> field.
}. }.
fields() -> fields() ->
[ {enable, fun enable/1} [ {enable, fun enable/1}
, {init_file, fun init_file/1} , {init_file, fun init_file/1}
, {separator, fun separator/1} , {separator, fun separator/1}
, {chunk_size, fun chunk_size/1} , {chunk_size, fun chunk_size/1}
]. ].

View File

@ -131,7 +131,7 @@ config(get, _) ->
config(put, #{body := Body}) -> config(put, #{body := Body}) ->
try try
{ok, _} = emqx_retainer:update_config(Body), {ok, _} = emqx_retainer:update_config(Body),
{200, emqx:get_raw_config([retainer])} {200, emqx:get_raw_config([retainer])}
catch _:Reason:_ -> catch _:Reason:_ ->
{400, {400,
#{code => 'UPDATE_FAILED', #{code => 'UPDATE_FAILED',

View File

@ -36,7 +36,7 @@ fields("statsd") ->
[ {enable, hoconsc:mk(boolean(), #{default => false, nullable => false})} [ {enable, hoconsc:mk(boolean(), #{default => false, nullable => false})}
, {server, fun server/1} , {server, fun server/1}
, {sample_time_interval, fun duration_ms/1} , {sample_time_interval, fun duration_ms/1}
, {flush_time_interval, fun duration_ms/1} , {flush_time_interval, fun duration_ms/1}
]. ].
server(type) -> emqx_schema:ip_port(); server(type) -> emqx_schema:ip_port();

View File

@ -10,7 +10,7 @@
+ **Supported architectures** + **Supported architectures**
`amd64`, `arm64v8`, `arm32v7`, `i386`, `s390x` `amd64`, `arm64v8`, `arm32v7`, `i386`, `s390x`
+ **Supported Docker versions**: + **Supported Docker versions**:
@ -21,7 +21,7 @@
[EMQ X MQTT broker](https://emqx.io/products/broker) is a fully open source, highly scalable, highly available distributed MQTT messaging broker for IoT, M2M and Mobile applications that can handle tens of millions of concurrent clients. [EMQ X MQTT broker](https://emqx.io/products/broker) is a fully open source, highly scalable, highly available distributed MQTT messaging broker for IoT, M2M and Mobile applications that can handle tens of millions of concurrent clients.
Starting from 3.0 release, *EMQ X* broker fully supports MQTT V5.0 protocol specifications and backward compatible with MQTT V3.1 and V3.1.1, as well as other communication protocols such as MQTT-SN, CoAP, LwM2M, WebSocket and STOMP. The 3.0 release of the *EMQ X* broker can scaled to 10+ million concurrent MQTT connections on one cluster. Starting from 3.0 release, *EMQ X* broker fully supports MQTT V5.0 protocol specifications and backward compatible with MQTT V3.1 and V3.1.1, as well as other communication protocols such as MQTT-SN, CoAP, LwM2M, WebSocket and STOMP. The 3.0 release of the *EMQ X* broker can scaled to 10+ million concurrent MQTT connections on one cluster.
# How to use this image # How to use this image