emqx.hrl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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(PERSISTENT_SESSION_SHARD, emqx_persistent_session_shard).
  25. -define(BOOT_SHARDS, [
  26. ?ROUTE_SHARD,
  27. ?COMMON_SHARD,
  28. ?SHARED_SUB_SHARD,
  29. ?PERSISTENT_SESSION_SHARD
  30. ]).
  31. %% Banner
  32. %%--------------------------------------------------------------------
  33. -define(PROTOCOL_VERSION, "MQTT/5.0").
  34. -define(ERTS_MINIMUM_REQUIRED, "10.0").
  35. %%--------------------------------------------------------------------
  36. %% Topics' prefix: $SYS | $share
  37. %%--------------------------------------------------------------------
  38. %% System topic
  39. -define(SYSTOP, <<"$SYS/">>).
  40. %%--------------------------------------------------------------------
  41. %% alarms
  42. %%--------------------------------------------------------------------
  43. -define(ACTIVATED_ALARM, emqx_activated_alarm).
  44. -define(DEACTIVATED_ALARM, emqx_deactivated_alarm).
  45. -define(TRIE, emqx_trie).
  46. %%--------------------------------------------------------------------
  47. %% Message and Delivery
  48. %%--------------------------------------------------------------------
  49. -record(subscription, {topic, subid, subopts}).
  50. %% See 'Application Message' in MQTT Version 5.0
  51. -record(message, {
  52. %% Global unique message ID
  53. id :: binary(),
  54. %% Message QoS
  55. qos = 0,
  56. %% Message from
  57. from :: atom() | binary(),
  58. %% Message flags
  59. flags = #{} :: emqx_types:flags(),
  60. %% Message headers. May contain any metadata. e.g. the
  61. %% protocol version number, username, peerhost or
  62. %% the PUBLISH properties (MQTT 5.0).
  63. headers = #{} :: emqx_types:headers(),
  64. %% Topic that the message is published to
  65. topic :: emqx_types:topic(),
  66. %% Message Payload
  67. payload :: emqx_types:payload(),
  68. %% Timestamp (Unit: millisecond)
  69. timestamp :: integer(),
  70. %% not used so far, for future extension
  71. extra = [] :: term()
  72. }).
  73. -record(delivery, {
  74. %% Sender of the delivery
  75. sender :: pid(),
  76. %% The message delivered
  77. message :: #message{}
  78. }).
  79. %%--------------------------------------------------------------------
  80. %% Route
  81. %%--------------------------------------------------------------------
  82. -record(route, {
  83. topic :: binary(),
  84. dest :: node() | {binary(), node()} | emqx_session:sessionID()
  85. }).
  86. %%--------------------------------------------------------------------
  87. %% Command
  88. %%--------------------------------------------------------------------
  89. -record(command, {
  90. name :: atom(),
  91. action :: atom(),
  92. args = [] :: list(),
  93. opts = [] :: list(),
  94. usage :: string(),
  95. descr :: string()
  96. }).
  97. %%--------------------------------------------------------------------
  98. %% Banned
  99. %%--------------------------------------------------------------------
  100. -record(banned, {
  101. who ::
  102. {clientid, binary()}
  103. | {peerhost, inet:ip_address()}
  104. | {username, binary()},
  105. by :: binary(),
  106. reason :: binary(),
  107. at :: integer(),
  108. until :: integer()
  109. }).
  110. %%--------------------------------------------------------------------
  111. %% Authentication
  112. %%--------------------------------------------------------------------
  113. -record(authenticator, {
  114. id :: binary(),
  115. provider :: module(),
  116. enable :: boolean(),
  117. state :: map()
  118. }).
  119. -record(chain, {
  120. name :: atom(),
  121. authenticators :: [#authenticator{}]
  122. }).
  123. -endif.