|
@@ -16,11 +16,16 @@
|
|
|
|
|
|
|
|
-module(emqx_persistent_message).
|
|
-module(emqx_persistent_message).
|
|
|
|
|
|
|
|
|
|
+-behaviour(emqx_config_handler).
|
|
|
|
|
+
|
|
|
-include("emqx.hrl").
|
|
-include("emqx.hrl").
|
|
|
|
|
|
|
|
-export([init/0]).
|
|
-export([init/0]).
|
|
|
-export([is_persistence_enabled/0, force_ds/0]).
|
|
-export([is_persistence_enabled/0, force_ds/0]).
|
|
|
|
|
|
|
|
|
|
+%% Config handler
|
|
|
|
|
+-export([add_handler/0, pre_config_update/3]).
|
|
|
|
|
+
|
|
|
%% Message persistence
|
|
%% Message persistence
|
|
|
-export([
|
|
-export([
|
|
|
persist/1
|
|
persist/1
|
|
@@ -66,6 +71,19 @@ storage_backend(Path) ->
|
|
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
%%--------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
+-spec add_handler() -> ok.
|
|
|
|
|
+add_handler() ->
|
|
|
|
|
+ emqx_conf:add_handler([session_persistence], ?MODULE).
|
|
|
|
|
+
|
|
|
|
|
+pre_config_update([session_persistence], #{<<"enable">> := New}, #{<<"enable">> := Old}) when
|
|
|
|
|
+ New =/= Old
|
|
|
|
|
+->
|
|
|
|
|
+ {error, "Hot update of session_persistence.enable parameter is currently not supported"};
|
|
|
|
|
+pre_config_update(_Root, _NewConf, _OldConf) ->
|
|
|
|
|
+ ok.
|
|
|
|
|
+
|
|
|
|
|
+%%--------------------------------------------------------------------
|
|
|
|
|
+
|
|
|
-spec persist(emqx_types:message()) ->
|
|
-spec persist(emqx_types:message()) ->
|
|
|
ok | {skipped, _Reason} | {error, _TODO}.
|
|
ok | {skipped, _Reason} | {error, _TODO}.
|
|
|
persist(Msg) ->
|
|
persist(Msg) ->
|