Просмотр исходного кода

refactor: fork clientid type for `emqx_ds:session_id/0`

Thales Macedo Garitezi 2 лет назад
Родитель
Сommit
23d63f5e01

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

@@ -185,8 +185,7 @@ ensure_all_iterators_closed(DSSessionID) ->
 
 %% RPC target.
 -spec do_ensure_all_iterators_closed(emqx_ds:session_id()) -> ok.
-do_ensure_all_iterators_closed(DSSessionID0) ->
-    DSSessionID = bin(DSSessionID0),
+do_ensure_all_iterators_closed(DSSessionID) ->
     ok = emqx_ds_storage_layer:discard_iterator_prefix(?DS_SHARD, DSSessionID),
     ok.
 
@@ -202,6 +201,3 @@ deserialize_message(Bin) ->
 
 is_store_enabled() ->
     emqx_config:get([persistent_session_store, ds]).
-
-bin(B) when is_binary(B) -> B;
-bin(A) when is_atom(A) -> atom_to_binary(A, utf8).

+ 3 - 1
apps/emqx_durable_storage/src/emqx_ds.erl

@@ -58,7 +58,9 @@
 %% Type declarations
 %%================================================================================
 
--type session_id() :: emqx_types:clientid().
+%% Currently, this is the clientid.  We avoid `emqx_types:clientid()' because that can be
+%% an atom, in theory (?).
+-type session_id() :: binary().
 
 -type iterator() :: term().