Format code

This commit is contained in:
Feng Lee 2017-08-12 12:51:02 +08:00
parent 8cb07b6299
commit f28db8b4c7
1 changed files with 29 additions and 21 deletions

View File

@ -49,6 +49,7 @@ register_config_cli() ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Auth/Acl %% Auth/Acl
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_auth_config() -> register_auth_config() ->
ConfigKeys = ["mqtt.allow_anonymous", ConfigKeys = ["mqtt.allow_anonymous",
"mqtt.acl_nomatch", "mqtt.acl_nomatch",
@ -58,17 +59,17 @@ register_auth_config() ->
ok = register_config_whitelist(ConfigKeys). ok = register_config_whitelist(ConfigKeys).
auth_config_callback([_, KeyStr], Value) -> auth_config_callback([_, KeyStr], Value) ->
application:set_env(?APP, l2a(KeyStr), Value), application:set_env(?APP, l2a(KeyStr), Value), " successfully\n".
" successfully\n".
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Protocol %% MQTT Protocol
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_protocol_formatter() -> register_protocol_formatter() ->
ConfigKeys = ["max_clientid_len", ConfigKeys = ["max_clientid_len",
"max_packet_size", "max_packet_size",
"websocket_protocol_header", "websocket_protocol_header",
"keepalive_backoff"], "keepalive_backoff"],
[clique:register_formatter(["mqtt", Key], fun protocol_formatter_callback/2) || Key <- ConfigKeys]. [clique:register_formatter(["mqtt", Key], fun protocol_formatter_callback/2) || Key <- ConfigKeys].
protocol_formatter_callback([_, Key], Params) -> protocol_formatter_callback([_, Key], Params) ->
@ -92,6 +93,7 @@ protocol_config_callback(App, Key, Value) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Connection %% MQTT Connection
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_connection_config() -> register_connection_config() ->
ConfigKeys = ["mqtt.conn.force_gc_count"], ConfigKeys = ["mqtt.conn.force_gc_count"],
[clique:register_config(Key , fun connection_config_callback/2) || Key <- ConfigKeys], [clique:register_config(Key , fun connection_config_callback/2) || Key <- ConfigKeys],
@ -105,10 +107,11 @@ connection_config_callback([_, KeyStr0, KeyStr1], Value) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Client %% MQTT Client
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_client_formatter() -> register_client_formatter() ->
ConfigKeys = ["max_publish_rate", ConfigKeys = ["max_publish_rate",
"idle_timeout", "idle_timeout",
"enable_stats"], "enable_stats"],
[clique:register_formatter(["mqtt", "client", Key], fun client_formatter_callback/2) || Key <- ConfigKeys]. [clique:register_formatter(["mqtt", "client", Key], fun client_formatter_callback/2) || Key <- ConfigKeys].
client_formatter_callback([_, _, Key], Params) -> client_formatter_callback([_, _, Key], Params) ->
@ -131,16 +134,17 @@ client_config_callback(App, Key, Value) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% session %% session
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_session_formatter() -> register_session_formatter() ->
ConfigKeys = ["max_subscriptions", ConfigKeys = ["max_subscriptions",
"upgrade_qos", "upgrade_qos",
"max_inflight", "max_inflight",
"retry_interval", "retry_interval",
"max_awaiting_rel", "max_awaiting_rel",
"await_rel_timeout", "await_rel_timeout",
"enable_stats", "enable_stats",
"expiry_interval", "expiry_interval",
"ignore_loop_deliver"], "ignore_loop_deliver"],
[clique:register_formatter(["mqtt", "session", Key], fun session_formatter_callback/2) || Key <- ConfigKeys]. [clique:register_formatter(["mqtt", "session", Key], fun session_formatter_callback/2) || Key <- ConfigKeys].
session_formatter_callback([_, _, Key], Params) -> session_formatter_callback([_, _, Key], Params) ->
@ -171,13 +175,14 @@ l2a(List) -> list_to_atom(List).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT MQueue %% MQTT MQueue
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_queue_formatter() -> register_queue_formatter() ->
ConfigKeys = ["type", ConfigKeys = ["type",
"priority", "priority",
"max_length", "max_length",
"low_watermark", "low_watermark",
"high_watermark", "high_watermark",
"store_qos0"], "store_qos0"],
[clique:register_formatter(["mqtt", "mqueue", Key], fun queue_formatter_callback/2) || Key <- ConfigKeys]. [clique:register_formatter(["mqtt", "mqueue", Key], fun queue_formatter_callback/2) || Key <- ConfigKeys].
queue_formatter_callback([_, _, Key], Params) -> queue_formatter_callback([_, _, Key], Params) ->
@ -203,6 +208,7 @@ queue_config_callback(App, Key, Value) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Broker %% MQTT Broker
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_broker_config() -> register_broker_config() ->
ConfigKeys = ["mqtt.broker.sys_interval"], ConfigKeys = ["mqtt.broker.sys_interval"],
[clique:register_config(Key , fun broker_config_callback/2) || Key <- ConfigKeys], [clique:register_config(Key , fun broker_config_callback/2) || Key <- ConfigKeys],
@ -216,6 +222,7 @@ broker_config_callback([_, KeyStr0, KeyStr1], Value) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Lager %% MQTT Lager
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
register_lager_formatter() -> register_lager_formatter() ->
ConfigKeys = ["level"], ConfigKeys = ["level"],
[clique:register_formatter(["log", "console", Key], fun lager_formatter_callback/2) || Key <- ConfigKeys]. [clique:register_formatter(["log", "console", Key], fun lager_formatter_callback/2) || Key <- ConfigKeys].
@ -234,3 +241,4 @@ lager_config_callback(_, Value) ->
register_config_whitelist(ConfigKeys) -> register_config_whitelist(ConfigKeys) ->
clique:register_config_whitelist(ConfigKeys, ?APP). clique:register_config_whitelist(ConfigKeys, ?APP).