emqx.hrl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2017-2023 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. %% Queue topic
  35. -define(QUEUE, <<"$queue/">>).
  36. %%--------------------------------------------------------------------
  37. %% alarms
  38. %%--------------------------------------------------------------------
  39. -define(ACTIVATED_ALARM, emqx_activated_alarm).
  40. -define(DEACTIVATED_ALARM, emqx_deactivated_alarm).
  41. -define(TRIE, emqx_trie).
  42. %%--------------------------------------------------------------------
  43. %% Message and Delivery
  44. %%--------------------------------------------------------------------
  45. -record(subscription, {topic, subid, subopts}).
  46. %% See 'Application Message' in MQTT Version 5.0
  47. -record(message, {
  48. %% Global unique message ID
  49. id :: binary(),
  50. %% Message QoS
  51. qos = 0,
  52. %% Message from
  53. from :: atom() | binary(),
  54. %% Message flags
  55. flags = #{} :: emqx_types:flags(),
  56. %% Message headers. May contain any metadata. e.g. the
  57. %% protocol version number, username, peerhost or
  58. %% the PUBLISH properties (MQTT 5.0).
  59. headers = #{} :: emqx_types:headers(),
  60. %% Topic that the message is published to
  61. topic :: emqx_types:topic(),
  62. %% Message Payload
  63. payload :: emqx_types:payload(),
  64. %% Timestamp (Unit: millisecond)
  65. timestamp :: integer(),
  66. %% not used so far, for future extension
  67. extra = [] :: term()
  68. }).
  69. -record(delivery, {
  70. %% Sender of the delivery
  71. sender :: pid(),
  72. %% The message delivered
  73. message :: #message{}
  74. }).
  75. %%--------------------------------------------------------------------
  76. %% Route
  77. %%--------------------------------------------------------------------
  78. -record(route, {
  79. topic :: binary(),
  80. dest :: node() | {binary(), node()} | emqx_session:session_id()
  81. }).
  82. %%--------------------------------------------------------------------
  83. %% Command
  84. %%--------------------------------------------------------------------
  85. -record(command, {
  86. name :: atom(),
  87. action :: atom(),
  88. args = [] :: list(),
  89. opts = [] :: list(),
  90. usage :: string(),
  91. descr :: string()
  92. }).
  93. %%--------------------------------------------------------------------
  94. %% Banned
  95. %%--------------------------------------------------------------------
  96. -record(banned, {
  97. who ::
  98. {clientid, binary()}
  99. | {peerhost, inet:ip_address()}
  100. | {username, binary()},
  101. by :: binary(),
  102. reason :: binary(),
  103. at :: integer(),
  104. until :: integer()
  105. }).
  106. -endif.