emqx.hrl 5.1 KB

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