diff --git a/emqx-plugin-templates/rebar.config b/emqx-plugin-templates/rebar.config index e3df41b0..9c327955 100644 --- a/emqx-plugin-templates/rebar.config +++ b/emqx-plugin-templates/rebar.config @@ -2,14 +2,14 @@ %% -*- mode: erlang -*- {deps, [ {emqx_plugin_helper, - {git, "https://github.com/emqx/emqx-plugin-helper.git", {tag, "v5.9.0"}}}, + {git, "https://github.com/emqx/emqx-plugin-helper.git", {tag, "@@emqx_plugin_helper_vsn@@"}}}, %% this is my plugin's dependency {map_sets, "1.1.0"} ]}. {plugins, [ {emqx_plugin_helper, - {git, "https://github.com/emqx/emqx-plugin-helper.git", {tag, "v5.9.0"}}}, + {git, "https://github.com/emqx/emqx-plugin-helper.git", {tag, "@@emqx_plugin_helper_vsn@@"}}}, {erlfmt, "1.6.0"} ]}. diff --git a/emqx-plugin-templates/src/emqx_plugin_template.erl b/emqx-plugin-templates/src/emqx_plugin_template.erl index 45522419..7e905c04 100644 --- a/emqx-plugin-templates/src/emqx_plugin_template.erl +++ b/emqx-plugin-templates/src/emqx_plugin_template.erl @@ -2,7 +2,7 @@ -module(@@name@@). -define(PLUGIN_NAME, "@@name@@"). --define(PLUGIN_VSN, "1.0.0"). +-define(PLUGIN_VSN, "@@version@@"). %% for #message{} record %% no need for this include if we call emqx_message:to_map/1 to convert it to a map @@ -116,6 +116,8 @@ on_client_connect(ConnInfo, Props, some_arg) -> {ok, Props}. %% @doc +%% This a fold hook callback. +%% %% - Return `{stop, ok}' if this client is to be allowed to login. %% - Return `{stop, {error, not_authorized}}' if this client is not allowed to login. %% - Return `ignore' if this client is to be authenticated by other plugins @@ -136,6 +138,8 @@ on_client_authenticate(#{clientid := ClientId} = _ClientInfo, DefaultResult) -> end. %% @doc +%% This is a fold hook callback. +%% %% - To permit/forbid actions, return `{stop, #{result => Result}}' where `Result' is either `allow' or `deny'. %% - Return `ignore' if this client is to be authorized by other plugins or %% EMQX's built-in authorization sources. @@ -165,7 +169,7 @@ on_client_authorize(_ClientInfo = #{clientid := ClientId}, Action, Topic, _Resul ignore. %% @doc -%% Demo callback working with messages. +%% Demo callback working with messages. This is a fold hook callback. on_message_puback(_PacketId, #message{} = Message, PubRes, RC) -> NewRC = case RC of @@ -268,4 +272,5 @@ handle_info(_Request, State) -> {noreply, State}. terminate(_Reason, _State) -> + persistent_term:erase(?MODULE), ok. diff --git a/emqx-plugin.template b/emqx-plugin.template index 484563ed..0253f6ac 100644 --- a/emqx-plugin.template +++ b/emqx-plugin.template @@ -3,7 +3,7 @@ {description, "Another amazing EMQX plugin."}, {version, "1.0.0", "The release version of this plugin."}, {app_vsn, "0.1.0", "The erlang application vsn value."}, - {emqx_vsn, "e5.9.0-beta.1", "EMQX version to use as a dependency."}, + {emqx_plugin_helper_vsn, "v5.9.0", "EMQX Plugin helper to use as a dependency."}, {license, "Apache-2.0", "Short identifier for license you want to distribute this plugin under."}, {author_website, "http://example.com", "A website with details about the author."}, {repo, "https://github.com/emqx/emqx-plugin-template", "Where to find the source code for this plugin."}