Kaynağa Gözat

fix(emqx): Move bpapi and emqx message record to emqx_utils app

ieQu1 2 yıl önce
ebeveyn
işleme
7cb0322856

+ 1 - 6
apps/emqx/include/bpapi.hrl

@@ -14,9 +14,4 @@
 %% limitations under the License.
 %%--------------------------------------------------------------------
 
--ifndef(EMQX_BPAPI_HRL).
--define(EMQX_BPAPI_HRL, true).
-
--compile({parse_transform, emqx_bpapi_trans}).
-
--endif.
+-include_lib("emqx_utils/include/bpapi.hrl").

+ 1 - 23
apps/emqx/include/emqx.hrl

@@ -55,29 +55,7 @@
 
 -record(subscription, {topic, subid, subopts}).
 
-%% See 'Application Message' in MQTT Version 5.0
--record(message, {
-    %% Global unique message ID
-    id :: binary(),
-    %% Message QoS
-    qos = 0,
-    %% Message from
-    from :: atom() | binary(),
-    %% Message flags
-    flags = #{} :: emqx_types:flags(),
-    %% Message headers. May contain any metadata. e.g. the
-    %% protocol version number, username, peerhost or
-    %% the PUBLISH properties (MQTT 5.0).
-    headers = #{} :: emqx_types:headers(),
-    %% Topic that the message is published to
-    topic :: emqx_types:topic(),
-    %% Message Payload
-    payload :: emqx_types:payload(),
-    %% Timestamp (Unit: millisecond)
-    timestamp :: integer(),
-    %% not used so far, for future extension
-    extra = [] :: term()
-}).
+-include_lib("emqx_utils/include/emqx_message.hrl").
 
 -record(delivery, {
     %% Sender of the delivery

+ 1 - 1
apps/emqx_durable_storage/src/emqx_ds_storage_bitfield_lts.erl

@@ -31,7 +31,7 @@
 
 -export_type([options/0]).
 
--include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx_utils/include/emqx_message.hrl").
 -include_lib("snabbkaffe/include/trace.hrl").
 
 %%================================================================================

+ 1 - 1
apps/emqx_durable_storage/src/emqx_ds_storage_reference.erl

@@ -34,7 +34,7 @@
 
 -export_type([options/0]).
 
--include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx_utils/include/emqx_message.hrl").
 
 %%================================================================================
 %% Type declarations

+ 1 - 1
apps/emqx_durable_storage/src/emqx_durable_storage.app.src

@@ -5,7 +5,7 @@
     {vsn, "0.1.6"},
     {modules, []},
     {registered, []},
-    {applications, [kernel, stdlib, rocksdb, gproc, mria]},
+    {applications, [kernel, stdlib, rocksdb, gproc, mria, emqx_utils]},
     {mod, {emqx_ds_app, []}},
     {env, []}
 ]}.

+ 1 - 1
apps/emqx_durable_storage/src/proto/emqx_ds_proto_v1.erl

@@ -17,7 +17,7 @@
 
 -behavior(emqx_bpapi).
 
--include_lib("emqx/include/bpapi.hrl").
+-include_lib("emqx_utils/include/bpapi.hrl").
 %% API:
 -export([open_shard/3, drop_shard/2, get_streams/4, make_iterator/5, next/4]).
 

+ 22 - 0
apps/emqx_utils/include/bpapi.hrl

@@ -0,0 +1,22 @@
+%%--------------------------------------------------------------------
+%% Copyright (c) 2017-2023 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.
+%%--------------------------------------------------------------------
+
+-ifndef(EMQX_BPAPI_HRL).
+-define(EMQX_BPAPI_HRL, true).
+
+-compile({parse_transform, emqx_bpapi_trans}).
+
+-endif.

+ 43 - 0
apps/emqx_utils/include/emqx_message.hrl

@@ -0,0 +1,43 @@
+%%--------------------------------------------------------------------
+%% Copyright (c) 2022-2023 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.
+%%--------------------------------------------------------------------
+-ifndef(EMQX_MESSAGE_HRL).
+-define(EMQX_MESSAGE_HRL, true).
+
+%% See 'Application Message' in MQTT Version 5.0
+-record(message, {
+    %% Global unique message ID
+    id :: binary(),
+    %% Message QoS
+    qos = 0,
+    %% Message from
+    from :: atom() | binary(),
+    %% Message flags
+    flags = #{} :: emqx_types:flags(),
+    %% Message headers. May contain any metadata. e.g. the
+    %% protocol version number, username, peerhost or
+    %% the PUBLISH properties (MQTT 5.0).
+    headers = #{} :: emqx_types:headers(),
+    %% Topic that the message is published to
+    topic :: emqx_types:topic(),
+    %% Message Payload
+    payload :: emqx_types:payload(),
+    %% Timestamp (Unit: millisecond)
+    timestamp :: integer(),
+    %% not used so far, for future extension
+    extra = [] :: term()
+}).
+
+-endif.

apps/emqx/src/bpapi/emqx_bpapi_trans.erl → apps/emqx_utils/src/bpapi/emqx_bpapi_trans.erl