0.14
This commit is contained in:
parent
4deb96dc91
commit
cfaa0c5e40
1
TODO
1
TODO
|
@ -11,3 +11,4 @@ TODO 5. dashboard
|
||||||
|
|
||||||
TODO 6. emqttd_ctl
|
TODO 6. emqttd_ctl
|
||||||
|
|
||||||
|
TODO 7. transaction on route, and topic?
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd main module.
|
%%% @doc emqttd main module.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd).
|
-module(emqttd).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Authentication and ACL Control Server
|
%%% @doc Authentication and ACL Control Server
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_access_control).
|
-module(emqttd_access_control).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd ACL Rule
|
%%% @doc emqttd ACL Rule
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_access_rule).
|
-module(emqttd_access_rule).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Internal ACL that load rules from etc/acl.config
|
%%% @doc Internal ACL that load rules from etc/acl.config
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_acl_internal).
|
-module(emqttd_acl_internal).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc ACL module behaviour
|
%%% @doc ACL module behaviour
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_acl_mod).
|
-module(emqttd_acl_mod).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Copy alarm_handler
|
%%% @doc Copy alarm_handler
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_alarm).
|
-module(emqttd_alarm).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd application.
|
%%% @doc emqttd application.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_app).
|
-module(emqttd_app).
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,9 @@
|
||||||
%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
%%% SOFTWARE.
|
%%% SOFTWARE.
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
%%% @doc Anonymous authentication module
|
%%% @doc Anonymous Authentication Module
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_auth_anonymous).
|
-module(emqttd_auth_anonymous).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc ClientId Authentication Module
|
%%% @doc ClientId Authentication Module
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_auth_clientid).
|
-module(emqttd_auth_clientid).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc LDAP Authentication Module
|
%%% @doc LDAP Authentication Module
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_auth_ldap).
|
-module(emqttd_auth_ldap).
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,9 @@
|
||||||
%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
%%% SOFTWARE.
|
%%% SOFTWARE.
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
%%% @doc emqttd authentication behaviour
|
%%% @doc emqttd Authentication Behaviour
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_auth_mod).
|
-module(emqttd_auth_mod).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Authentication with username and password
|
%%% @doc Authentication with username and password
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_auth_username).
|
-module(emqttd_auth_username).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd bridge
|
%%% @doc emqttd bridge
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_bridge).
|
-module(emqttd_bridge).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Bridge Supervisor
|
%%% @doc Bridge Supervisor
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_bridge_sup).
|
-module(emqttd_bridge_sup).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd broker
|
%%% @doc emqttd broker
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_broker).
|
-module(emqttd_broker).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd cli
|
%%% @doc emqttd cli
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_cli).
|
-module(emqttd_cli).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc MQTT Client Connection
|
%%% @doc MQTT Client Connection
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_client).
|
-module(emqttd_client).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc MQTT Client Manager
|
%%% @doc MQTT Client Manager
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_cm).
|
-module(emqttd_cm).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Client Manager Supervisor.
|
%%% @doc Client Manager Supervisor.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_cm_sup).
|
-module(emqttd_cm_sup).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd control
|
%%% @doc emqttd control
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_ctl).
|
-module(emqttd_ctl).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd distribution functions
|
%%% @doc emqttd distribution functions
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_dist).
|
-module(emqttd_dist).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd gen_mod behaviour
|
%%% @doc emqttd gen_mod behaviour
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_gen_mod).
|
-module(emqttd_gen_mod).
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_guid).
|
-module(emqttd_guid).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd http publish API and websocket client.
|
%%% @doc emqttd http publish API and websocket client.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_http).
|
-module(emqttd_http).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc MQTT Message Functions
|
%%% @doc MQTT Message Functions
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_message).
|
-module(emqttd_message).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd metrics. responsible for collecting broker metrics
|
%%% @doc emqttd metrics. responsible for collecting broker metrics
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_metrics).
|
-module(emqttd_metrics).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd mnesia
|
%%% @doc emqttd mnesia
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_mnesia).
|
-module(emqttd_mnesia).
|
||||||
|
|
||||||
|
@ -121,7 +120,7 @@ copy_table(Table) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
wait_for_tables() ->
|
wait_for_tables() ->
|
||||||
%%TODO: is not right?
|
%%TODO: is not right?
|
||||||
%%lager:info("local_tables: ~p", [mnesia:system_info(local_tables)]),
|
io:format("mnesia wait_for_tables: ~p~n", [mnesia:system_info(local_tables)]),
|
||||||
mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity).
|
mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity).
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd auto subscribe module.
|
%%% @doc emqttd auto subscribe module.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_mod_autosub).
|
-module(emqttd_mod_autosub).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd presence management module
|
%%% @doc emqttd presence management module
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_mod_presence).
|
-module(emqttd_mod_presence).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd rewrite module
|
%%% @doc emqttd rewrite module
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_mod_rewrite).
|
-module(emqttd_mod_rewrite).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd module supervisor.
|
%%% @doc emqttd module supervisor.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_mod_sup).
|
-module(emqttd_mod_sup).
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_mqueue).
|
-module(emqttd_mqueue).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd net utility functions. some functions copied from rabbitmq.
|
%%% @doc emqttd net utility functions. some functions copied from rabbitmq.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_net).
|
-module(emqttd_net).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd options handler.
|
%%% @doc emqttd options handler.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_opts).
|
-module(emqttd_opts).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc MQTT Packet Functions
|
%%% @doc MQTT Packet Functions
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_packet).
|
-module(emqttd_packet).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc MQTT Packet Parser
|
%%% @doc MQTT Packet Parser
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_parser).
|
-module(emqttd_parser).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd plugins.
|
%%% @doc emqttd plugins.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_plugins).
|
-module(emqttd_plugins).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Common Pool Supervisor
|
%%% @doc Common Pool Supervisor
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_pool_sup).
|
-module(emqttd_pool_sup).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd pooler.
|
%%% @doc emqttd pooler.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_pooler).
|
-module(emqttd_pooler).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd protocol.
|
%%% @doc emqttd protocol.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_protocol).
|
-module(emqttd_protocol).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd pubsub
|
%%% @doc emqttd pubsub
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_pubsub).
|
-module(emqttd_pubsub).
|
||||||
|
|
||||||
|
@ -66,31 +65,46 @@
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
%%% Mnesia callbacks
|
%%% Mnesia callbacks
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
|
|
||||||
mnesia(boot) ->
|
mnesia(boot) ->
|
||||||
%% Topic Table
|
ok = create_table(topic, ram_copies),
|
||||||
ok = emqttd_mnesia:create_table(topic, [
|
case env(subscription) of
|
||||||
{type, bag},
|
disc -> ok = create_table(subscription, disc_copies);
|
||||||
{ram_copies, [node()]},
|
ram -> ok = create_table(subscription, ram_copies);
|
||||||
{record_name, mqtt_topic},
|
false -> ok
|
||||||
{attributes, record_info(fields, mqtt_topic)}]),
|
end;
|
||||||
RamOrDisc = case env(subscription) of
|
|
||||||
disc -> disc_copies;
|
|
||||||
_ -> ram_copies
|
|
||||||
end,
|
|
||||||
%% Subscription Table
|
|
||||||
ok = emqttd_mnesia:create_table(subscription, [
|
|
||||||
{type, bag},
|
|
||||||
{RamOrDisc, [node()]},
|
|
||||||
{record_name, mqtt_subscription},
|
|
||||||
{attributes, record_info(fields, mqtt_subscription)}]);
|
|
||||||
|
|
||||||
mnesia(copy) ->
|
mnesia(copy) ->
|
||||||
ok = emqttd_mnesia:copy_table(topic),
|
ok = emqttd_mnesia:copy_table(topic),
|
||||||
ok = emqttd_mnesia:copy_table(subscription).
|
case env(subscription) of
|
||||||
|
false -> ok;
|
||||||
|
_ -> ok = emqttd_mnesia:copy_table(subscription)
|
||||||
|
end.
|
||||||
|
|
||||||
|
%% Topic Table
|
||||||
|
create_table(topic, RamOrDisc) ->
|
||||||
|
emqttd_mnesia:create_table(topic, [
|
||||||
|
{type, bag},
|
||||||
|
{RamOrDisc, [node()]},
|
||||||
|
{record_name, mqtt_topic},
|
||||||
|
{attributes, record_info(fields, mqtt_topic)}]);
|
||||||
|
|
||||||
|
%% Subscription Table
|
||||||
|
create_table(subscription, RamOrDisc) ->
|
||||||
|
emqttd_mnesia:create_table(subscription, [
|
||||||
|
{type, bag},
|
||||||
|
{RamOrDisc, [node()]},
|
||||||
|
{record_name, mqtt_subscription},
|
||||||
|
{attributes, record_info(fields, mqtt_subscription)}]).
|
||||||
|
|
||||||
env(Key) ->
|
env(Key) ->
|
||||||
proplists:get_value(Key, emqttd_broker:env(pubsub)).
|
case get({pubsub, Key}) of
|
||||||
|
undefined ->
|
||||||
|
Val = proplists:get_value(Key, emqttd_broker:env(pubsub)),
|
||||||
|
put({pubsub, Key}, Val),
|
||||||
|
Val;
|
||||||
|
Val ->
|
||||||
|
Val
|
||||||
|
end.
|
||||||
|
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
%%% API
|
%%% API
|
||||||
|
@ -309,7 +323,7 @@ remove_subscriptions(SubId, Topics) ->
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
|
|
||||||
trace(publish, From, _Msg) when is_atom(From) ->
|
trace(publish, From, _Msg) when is_atom(From) ->
|
||||||
%% Dont' trace broker publish
|
%% Dont' trace '$SYS' publish
|
||||||
ignore;
|
ignore;
|
||||||
|
|
||||||
trace(publish, From, #mqtt_message{topic = Topic, payload = Payload}) ->
|
trace(publish, From, #mqtt_message{topic = Topic, payload = Payload}) ->
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc PubSub Helper
|
%%% @doc PubSub Helper
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_pubsub_helper).
|
-module(emqttd_pubsub_helper).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc PubSub Supervisor
|
%%% @doc PubSub Supervisor
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_pubsub_sup).
|
-module(emqttd_pubsub_sup).
|
||||||
|
|
||||||
|
@ -39,8 +38,7 @@
|
||||||
-export([init/1]).
|
-export([init/1]).
|
||||||
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
Opts = emqttd_broker:env(pubsub),
|
supervisor:start_link({local, ?MODULE}, ?MODULE, [emqttd_broker:env(pubsub)]).
|
||||||
supervisor:start_link({local, ?MODULE}, ?MODULE, [Opts]).
|
|
||||||
|
|
||||||
init([Opts]) ->
|
init([Opts]) ->
|
||||||
%% PubSub Helper
|
%% PubSub Helper
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_retainer).
|
-module(emqttd_retainer).
|
||||||
|
|
||||||
|
@ -66,7 +65,6 @@ mnesia(boot) ->
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{record_name, mqtt_retained},
|
{record_name, mqtt_retained},
|
||||||
{attributes, record_info(fields, mqtt_retained)}]);
|
{attributes, record_info(fields, mqtt_retained)}]);
|
||||||
|
|
||||||
mnesia(copy) ->
|
mnesia(copy) ->
|
||||||
ok = emqttd_mnesia:copy_table(retained).
|
ok = emqttd_mnesia:copy_table(retained).
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_router).
|
-module(emqttd_router).
|
||||||
|
|
||||||
|
@ -40,8 +39,12 @@
|
||||||
|
|
||||||
-include("emqttd_protocol.hrl").
|
-include("emqttd_protocol.hrl").
|
||||||
|
|
||||||
-export([init/1, lookup/1, route/2, add_routes/2,
|
-export([init/1, route/2, lookup_routes/1,
|
||||||
delete_routes/1, delete_routes/2]).
|
add_routes/2, delete_routes/1, delete_routes/2]).
|
||||||
|
|
||||||
|
-ifdef(TEST).
|
||||||
|
-compile(export_all).
|
||||||
|
-endif.
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% @doc Create route tables.
|
%% @doc Create route tables.
|
||||||
|
@ -71,7 +74,7 @@ ensure_tab(Tab, Opts) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
-spec add_routes(list({binary(), mqtt_qos()}), pid()) -> ok.
|
-spec add_routes(list({binary(), mqtt_qos()}), pid()) -> ok.
|
||||||
add_routes(TopicTable, Pid) when is_pid(Pid) ->
|
add_routes(TopicTable, Pid) when is_pid(Pid) ->
|
||||||
case lookup(Pid) of
|
case lookup_routes(Pid) of
|
||||||
[] ->
|
[] ->
|
||||||
erlang:monitor(process, Pid),
|
erlang:monitor(process, Pid),
|
||||||
insert_routes(TopicTable, Pid);
|
insert_routes(TopicTable, Pid);
|
||||||
|
@ -85,8 +88,8 @@ add_routes(TopicTable, Pid) when is_pid(Pid) ->
|
||||||
%% @doc Lookup Routes
|
%% @doc Lookup Routes
|
||||||
%% @end
|
%% @end
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
-spec lookup(pid()) -> list({binary(), mqtt_qos()}).
|
-spec lookup_routes(pid()) -> list({binary(), mqtt_qos()}).
|
||||||
lookup(Pid) when is_pid(Pid) ->
|
lookup_routes(Pid) when is_pid(Pid) ->
|
||||||
[{Topic, Qos} || {_, Topic, Qos} <- ets:lookup(reverse_route, Pid)].
|
[{Topic, Qos} || {_, Topic, Qos} <- ets:lookup(reverse_route, Pid)].
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
@ -100,7 +103,7 @@ delete_routes(Topics, Pid) ->
|
||||||
|
|
||||||
-spec delete_routes(pid()) -> ok.
|
-spec delete_routes(pid()) -> ok.
|
||||||
delete_routes(Pid) when is_pid(Pid) ->
|
delete_routes(Pid) when is_pid(Pid) ->
|
||||||
Routes = [{Topic, Pid} || {Topic, _Qos} <- lookup(Pid)],
|
Routes = [{Topic, Pid} || {Topic, _Qos} <- lookup_routes(Pid)],
|
||||||
ets:delete(reverse_route, Pid),
|
ets:delete(reverse_route, Pid),
|
||||||
lists:foreach(fun delete_route_only/1, Routes).
|
lists:foreach(fun delete_route_only/1, Routes).
|
||||||
|
|
||||||
|
@ -112,7 +115,7 @@ delete_routes(Pid) when is_pid(Pid) ->
|
||||||
route(Queue = <<"$Q/", _Q>>, Msg) ->
|
route(Queue = <<"$Q/", _Q>>, Msg) ->
|
||||||
case ets:lookup(route, Queue) of
|
case ets:lookup(route, Queue) of
|
||||||
[] ->
|
[] ->
|
||||||
setstats(dropped, true);
|
emqttd_metrics:inc('messages/dropped');
|
||||||
Routes ->
|
Routes ->
|
||||||
Idx = crypto:rand_uniform(1, length(Routes) + 1),
|
Idx = crypto:rand_uniform(1, length(Routes) + 1),
|
||||||
{_, SubPid, SubQos} = lists:nth(Idx, Routes),
|
{_, SubPid, SubQos} = lists:nth(Idx, Routes),
|
||||||
|
@ -120,12 +123,15 @@ route(Queue = <<"$Q/", _Q>>, Msg) ->
|
||||||
end;
|
end;
|
||||||
|
|
||||||
route(Topic, Msg) ->
|
route(Topic, Msg) ->
|
||||||
Routes = ets:lookup(route, Topic),
|
case ets:lookup(route, Topic) of
|
||||||
setstats(dropped, Routes =:= []),
|
[] ->
|
||||||
lists:foreach(
|
emqttd_metrics:inc('messages/dropped');
|
||||||
fun({_Topic, SubPid, SubQos}) ->
|
Routes ->
|
||||||
SubPid ! {dispatch, tune_qos(SubQos, Msg)}
|
lists:foreach(
|
||||||
end, Routes).
|
fun({_Topic, SubPid, SubQos}) ->
|
||||||
|
SubPid ! {dispatch, tune_qos(SubQos, Msg)}
|
||||||
|
end, Routes)
|
||||||
|
end.
|
||||||
|
|
||||||
tune_qos(SubQos, Msg = #mqtt_message{qos = PubQos}) when PubQos > SubQos ->
|
tune_qos(SubQos, Msg = #mqtt_message{qos = PubQos}) when PubQos > SubQos ->
|
||||||
Msg#mqtt_message{qos = SubQos};
|
Msg#mqtt_message{qos = SubQos};
|
||||||
|
@ -185,8 +191,3 @@ delete_route({Topic, Pid}) ->
|
||||||
delete_route_only({Topic, Pid}) ->
|
delete_route_only({Topic, Pid}) ->
|
||||||
ets:match_delete(route, {Topic, Pid, '_'}).
|
ets:match_delete(route, {Topic, Pid, '_'}).
|
||||||
|
|
||||||
setstats(dropped, false) ->
|
|
||||||
ignore;
|
|
||||||
setstats(dropped, true) ->
|
|
||||||
emqttd_metrics:inc('messages/dropped').
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc MQTT Packet Serialiser
|
%%% @doc MQTT Packet Serialiser
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_serialiser).
|
-module(emqttd_serialiser).
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_session).
|
-module(emqttd_session).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd session supervisor.
|
%%% @doc emqttd session supervisor.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_session_sup).
|
-module(emqttd_session_sup).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Session Manager
|
%%% @doc Session Manager
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_sm).
|
-module(emqttd_sm).
|
||||||
|
|
||||||
|
@ -66,14 +65,14 @@
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
|
|
||||||
mnesia(boot) ->
|
mnesia(boot) ->
|
||||||
%% Global session...
|
%% Global Session Table
|
||||||
ok = emqttd_mnesia:create_table(session, [
|
ok = emqttd_mnesia:create_table(session, [
|
||||||
{type, ordered_set},
|
{type, ordered_set},
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{record_name, mqtt_session},
|
{record_name, mqtt_session},
|
||||||
{attributes, record_info(fields, mqtt_session)},
|
{attributes, record_info(fields, mqtt_session)},
|
||||||
{index, [sess_pid]}]);
|
%% TODO: index_read is slow...
|
||||||
|
{index, [sess_pid]}]);
|
||||||
mnesia(copy) ->
|
mnesia(copy) ->
|
||||||
ok = emqttd_mnesia:copy_table(session).
|
ok = emqttd_mnesia:copy_table(session).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Session Helper.
|
%%% @doc Session Helper.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_sm_helper).
|
-module(emqttd_sm_helper).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc Session Manager Supervisor.
|
%%% @doc Session Manager Supervisor.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_sm_sup).
|
-module(emqttd_sm_sup).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd top supervisor.
|
%%% @doc emqttd top supervisor.
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_sup).
|
-module(emqttd_sup).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc emqttd system monitor
|
%%% @doc emqttd system monitor
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_sysmon).
|
-module(emqttd_sysmon).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
%%% @doc MQTT Topic Functions
|
%%% @doc MQTT Topic Functions
|
||||||
%%%
|
%%%
|
||||||
%%% @author Feng Lee <feng@emqtt.io>
|
%%% @author Feng Lee <feng@emqtt.io>
|
||||||
%%%
|
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
-module(emqttd_topic).
|
-module(emqttd_topic).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue