Merge pull request #13135 from ieQu1/dev/refactor-sessds2

Refactor session DS code. No functional change.
This commit is contained in:
ieQu1 2024-05-28 10:24:15 +02:00 committed by GitHub
commit 02d10a2023
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 49 additions and 25 deletions

View File

@ -0,0 +1,35 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2022, 2024 EMQ Technologies Co., Ltd. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%--------------------------------------------------------------------
%% @doc This header contains definitions of durable session metadata
%% keys, that can be consumed by the external code.
-ifndef(EMQX_DURABLE_SESSION_META_HRL).
-define(EMQX_DURABLE_SESSION_META_HRL, true).
%% Session metadata keys:
-define(created_at, created_at).
-define(last_alive_at, last_alive_at).
-define(expiry_interval, expiry_interval).
%% Unique integer used to create unique identities:
-define(last_id, last_id).
%% Connection info (relevent for the dashboard):
-define(peername, peername).
-define(will_message, will_message).
-define(clientinfo, clientinfo).
-define(protocol, protocol).
-define(offline_info, offline_info).
-endif.

View File

@ -2,7 +2,7 @@
{application, emqx, [
{id, "emqx"},
{description, "EMQX Core"},
{vsn, "5.3.0"},
{vsn, "5.4.0"},
{modules, []},
{registered, []},
{applications, [

View File

@ -25,7 +25,7 @@
-include("emqx_mqtt.hrl").
-include("emqx_persistent_session_ds.hrl").
-include("emqx_persistent_session_ds/session_internals.hrl").
-ifdef(TEST).
-include_lib("proper/include/proper.hrl").

View File

@ -21,7 +21,7 @@
-include_lib("stdlib/include/qlc.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include("emqx_persistent_session_ds.hrl").
-include("session_internals.hrl").
%% API
-export([

View File

@ -21,7 +21,7 @@
-include_lib("stdlib/include/qlc.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include("emqx_persistent_session_ds.hrl").
-include("session_internals.hrl").
%% API
-export([

View File

@ -79,7 +79,7 @@
]).
-include("emqx_mqtt.hrl").
-include("emqx_persistent_session_ds.hrl").
-include("session_internals.hrl").
-include_lib("snabbkaffe/include/trace.hrl").
-include_lib("stdlib/include/qlc.hrl").

View File

@ -29,7 +29,7 @@
-include_lib("emqx/include/logger.hrl").
-include("emqx_mqtt.hrl").
-include("emqx_persistent_session_ds.hrl").
-include("session_internals.hrl").
%%================================================================================
%% Type declarations

View File

@ -41,7 +41,7 @@
-export_type([subscription_state_id/0, subscription/0, subscription_state/0]).
-include("emqx_persistent_session_ds.hrl").
-include("session_internals.hrl").
-include("emqx_mqtt.hrl").
-include_lib("snabbkaffe/include/trace.hrl").

View File

@ -13,10 +13,11 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%--------------------------------------------------------------------
-ifndef(EMQX_PERSISTENT_SESSION_DS_HRL_HRL).
-define(EMQX_PERSISTENT_SESSION_DS_HRL_HRL, true).
-ifndef(EMQX_SESSION_DS_INTERNALS_HRL).
-define(EMQX_SESSION_DS_INTERNALS_HRL, true).
-include("emqx_persistent_message.hrl").
-include("emqx_durable_session_metadata.hrl").
-define(SESSION_TAB, emqx_ds_session).
-define(SESSION_SUBSCRIPTIONS_TAB, emqx_ds_session_subscriptions).
@ -70,17 +71,4 @@
sub_state_id :: emqx_persistent_session_ds_subs:subscription_state_id()
}).
%% Session metadata keys:
-define(created_at, created_at).
-define(last_alive_at, last_alive_at).
-define(expiry_interval, expiry_interval).
%% Unique integer used to create unique identities:
-define(last_id, last_id).
%% Connection info (relevent for the dashboard):
-define(peername, peername).
-define(will_message, will_message).
-define(clientinfo, clientinfo).
-define(protocol, protocol).
-define(offline_info, offline_info).
-endif.

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_auth, [
{description, "EMQX Authentication and authorization"},
{vsn, "0.3.0"},
{vsn, "0.4.0"},
{modules, []},
{registered, [emqx_auth_sup]},
{applications, [

View File

@ -2,7 +2,7 @@
{application, emqx_management, [
{description, "EMQX Management API and CLI"},
% strict semver, bump manually!
{vsn, "5.2.0"},
{vsn, "5.3.0"},
{modules, []},
{registered, [emqx_management_sup]},
{applications, [

View File

@ -24,6 +24,7 @@
-include_lib("hocon/include/hoconsc.hrl").
-include_lib("emqx/include/logger.hrl").
-include_lib("emqx_utils/include/emqx_utils_api.hrl").
-include_lib("emqx/include/emqx_durable_session_metadata.hrl").
-include("emqx_mgmt.hrl").
@ -1739,7 +1740,7 @@ format_channel_info(undefined, {ClientId, PSInfo0 = #{}}, _Opts) ->
format_persistent_session_info(
_ClientId,
#{
metadata := #{offline_info := #{chan_info := ChanInfo, stats := Stats} = OfflineInfo} =
metadata := #{?offline_info := #{chan_info := ChanInfo, stats := Stats} = OfflineInfo} =
Metadata
} =
PSInfo