emqx.hrl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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(EMQ_X_HRL).
  17. -define(EMQ_X_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. %%--------------------------------------------------------------------
  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 :: pid(), %% Sender of the delivery
  75. message :: #message{} %% The message delivered
  76. }).
  77. %%--------------------------------------------------------------------
  78. %% Route
  79. %%--------------------------------------------------------------------
  80. -record(route, {
  81. topic :: binary(),
  82. dest :: node() | {binary(), node()} | emqx_session:sessionID()
  83. }).
  84. %%--------------------------------------------------------------------
  85. %% Plugin
  86. %%--------------------------------------------------------------------
  87. -record(plugin, {
  88. name :: atom(),
  89. dir :: string() | undefined,
  90. descr :: string(),
  91. vendor :: string() | undefined,
  92. active = false :: boolean(),
  93. info = #{} :: map()
  94. }).
  95. %%--------------------------------------------------------------------
  96. %% Command
  97. %%--------------------------------------------------------------------
  98. -record(command, {
  99. name :: atom(),
  100. action :: atom(),
  101. args = [] :: list(),
  102. opts = [] :: list(),
  103. usage :: string(),
  104. descr :: string()
  105. }).
  106. %%--------------------------------------------------------------------
  107. %% Banned
  108. %%--------------------------------------------------------------------
  109. -record(banned, {
  110. who :: {clientid, binary()}
  111. | {peerhost, inet:ip_address()}
  112. | {username, binary()},
  113. by :: binary(),
  114. reason :: binary(),
  115. at :: integer(),
  116. until :: integer()
  117. }).
  118. %%--------------------------------------------------------------------
  119. %% Authentication
  120. %%--------------------------------------------------------------------
  121. -record(authenticator,
  122. { id :: binary()
  123. , provider :: module()
  124. , enable :: boolean()
  125. , state :: map()
  126. }).
  127. -record(chain,
  128. { name :: atom()
  129. , authenticators :: [#authenticator{}]
  130. }).
  131. -endif.