emqx.hrl 4.3 KB

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