Преглед изворни кода

fix: dialyzer and xref warnings

Thales Macedo Garitezi пре 1 година
родитељ
комит
ba96fb7d95

+ 8 - 1
apps/emqx/src/emqx_persistent_session_ds.erl

@@ -82,7 +82,11 @@
 ]).
 ]).
 
 
 %% session table operations
 %% session table operations
--export([create_tables/0, sync/1]).
+-export([sync/1]).
+-ifndef(STORE_STATE_IN_DS).
+-export([create_tables/0]).
+%% END ifndef(STORE_STATE_IN_DS).
+-endif.
 
 
 %% internal export used by session GC process
 %% internal export used by session GC process
 -export([destroy_session/1]).
 -export([destroy_session/1]).
@@ -837,8 +841,11 @@ get_client_subscription(ClientId, TopicFilter) ->
 %% Session tables operations
 %% Session tables operations
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 
 
+-ifndef(STORE_STATE_IN_DS).
 create_tables() ->
 create_tables() ->
     emqx_persistent_session_ds_state:create_tables().
     emqx_persistent_session_ds_state:create_tables().
+%% END ifndef(STORE_STATE_IN_DS).
+-endif.
 
 
 %% @doc Force syncing of the transient state to persistent storage
 %% @doc Force syncing of the transient state to persistent storage
 sync(ClientId) ->
 sync(ClientId) ->

+ 9 - 1
apps/emqx/src/emqx_persistent_session_ds/emqx_persistent_session_ds_state.erl

@@ -116,7 +116,13 @@
 
 
 -opaque iter(K, V) :: gb_trees:iter(K, V).
 -opaque iter(K, V) :: gb_trees:iter(K, V).
 
 
+-ifdef(STORE_STATE_IN_DS).
+-opaque session_iterator() :: #{its := [emqx_ds:iterator()]} | '$end_of_table'.
+%% ELSE ifdef(STORE_STATE_IN_DS).
+-else.
 -opaque session_iterator() :: emqx_persistent_session_ds:id() | '$end_of_table'.
 -opaque session_iterator() :: emqx_persistent_session_ds:id() | '$end_of_table'.
+%% END ifdef(STORE_STATE_IN_DS).
+-endif.
 
 
 -ifndef(STORE_STATE_IN_DS).
 -ifndef(STORE_STATE_IN_DS).
 %% Generic key-value wrapper that is used for exporting arbitrary
 %% Generic key-value wrapper that is used for exporting arbitrary
@@ -462,6 +468,7 @@ delete(Id) ->
 commit(Rec) ->
 commit(Rec) ->
     commit(Rec, _Opts = #{}).
     commit(Rec, _Opts = #{}).
 
 
+-spec commit(t(), #{ensure_new => boolean()}) -> t().
 commit(Rec = #{dirty := false}, _Opts) ->
 commit(Rec = #{dirty := false}, _Opts) ->
     Rec;
     Rec;
 commit(
 commit(
@@ -543,12 +550,13 @@ store_batch(SessionId, Batch0, Opts) ->
             false ->
             false ->
                 Batch0
                 Batch0
         end,
         end,
-    emqx_ds:store_batch(?DB, Batch, #{atomic => true, sync => true}).
+    emqx_ds:store_batch(?DB, Batch, #{sync => true}).
 %% ELSE ifdef(STORE_STATE_IN_DS).
 %% ELSE ifdef(STORE_STATE_IN_DS).
 -else.
 -else.
 commit(Rec) ->
 commit(Rec) ->
     commit(Rec, _Opts = #{}).
     commit(Rec, _Opts = #{}).
 
 
+-spec commit(t(), #{ensure_new => boolean()}) -> t().
 commit(Rec = #{dirty := false}, _Opts) ->
 commit(Rec = #{dirty := false}, _Opts) ->
     Rec;
     Rec;
 commit(
 commit(

+ 2 - 1
apps/emqx/src/emqx_session.erl

@@ -198,7 +198,8 @@
 %% Create a Session
 %% Create a Session
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 
 
--spec create(clientinfo(), conninfo(), emqx_maybe:t(message())) -> {ok, t()} | {error, term()}.
+-spec create(clientinfo(), conninfo(), emqx_maybe:t(message())) ->
+    {ok, t()} | {error, recoverable | unrecoverable, term()}.
 create(ClientInfo, ConnInfo, MaybeWillMsg) ->
 create(ClientInfo, ConnInfo, MaybeWillMsg) ->
     Conf = get_session_conf(ClientInfo),
     Conf = get_session_conf(ClientInfo),
     % FIXME error conditions
     % FIXME error conditions