emqx.hrl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2017-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
  3. %%
  4. %% Licensed under the Apache License, Version 2.0 (the "License");
  5. %% you may not use this file except in compliance with the License.
  6. %% You may obtain a copy of the License at
  7. %%
  8. %% http://www.apache.org/licenses/LICENSE-2.0
  9. %%
  10. %% Unless required by applicable law or agreed to in writing, software
  11. %% distributed under the License is distributed on an "AS IS" BASIS,
  12. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. %% See the License for the specific language governing permissions and
  14. %% limitations under the License.
  15. %%--------------------------------------------------------------------
  16. -ifndef(EMQX_HRL).
  17. -define(EMQX_HRL, true).
  18. %% Shard
  19. %%--------------------------------------------------------------------
  20. -define(COMMON_SHARD, emqx_common_shard).
  21. -define(SHARED_SUB_SHARD, emqx_shared_sub_shard).
  22. -define(CM_SHARD, emqx_cm_shard).
  23. -define(ROUTE_SHARD, route_shard).
  24. -define(PS_ROUTER_SHARD, persistent_session_router_shard).
  25. %% Banner
  26. %%--------------------------------------------------------------------
  27. -define(PROTOCOL_VERSION, "MQTT/5.0").
  28. -define(ERTS_MINIMUM_REQUIRED, "10.0").
  29. %%--------------------------------------------------------------------
  30. %% Topics' prefix: $SYS | $queue | $share
  31. %%--------------------------------------------------------------------
  32. %% System topic
  33. -define(SYSTOP, <<"$SYS/">>).
  34. %%--------------------------------------------------------------------
  35. %% alarms
  36. %%--------------------------------------------------------------------
  37. -define(ACTIVATED_ALARM, emqx_activated_alarm).
  38. -define(DEACTIVATED_ALARM, emqx_deactivated_alarm).
  39. -define(TRIE, emqx_trie).
  40. %%--------------------------------------------------------------------
  41. %% Message and Delivery
  42. %%--------------------------------------------------------------------
  43. -record(subscription, {topic, subid, subopts}).
  44. -include_lib("emqx_utils/include/emqx_message.hrl").
  45. -record(delivery, {
  46. %% Sender of the delivery
  47. sender :: pid(),
  48. %% The message delivered
  49. message :: #message{}
  50. }).
  51. %%--------------------------------------------------------------------
  52. %% Route
  53. %%--------------------------------------------------------------------
  54. -record(share_dest, {
  55. session_id :: emqx_session:session_id(),
  56. group :: emqx_types:group()
  57. }).
  58. -record(route, {
  59. topic :: binary(),
  60. dest ::
  61. node()
  62. | {binary(), node()}
  63. | emqx_session:session_id()
  64. %% One session can also have multiple subscriptions to the same topic through different groups
  65. | #share_dest{}
  66. | emqx_external_broker:dest()
  67. }).
  68. %%--------------------------------------------------------------------
  69. %% Command
  70. %%--------------------------------------------------------------------
  71. -record(command, {
  72. name :: atom(),
  73. action :: atom(),
  74. args = [] :: list(),
  75. opts = [] :: list(),
  76. usage :: string(),
  77. descr :: string()
  78. }).
  79. %%--------------------------------------------------------------------
  80. %% Banned
  81. %%--------------------------------------------------------------------
  82. -record(banned, {
  83. who :: emqx_types:banned_who(),
  84. by :: binary(),
  85. reason :: binary(),
  86. at :: integer(),
  87. until :: integer() | infinity
  88. }).
  89. %%--------------------------------------------------------------------
  90. %% Configurations
  91. %%--------------------------------------------------------------------
  92. -define(KIND_REPLICATE, replicate).
  93. -define(KIND_INITIATE, initiate).
  94. -endif.