emqx.hrl 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2017-2021 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. %%--------------------------------------------------------------------
  19. %% Common
  20. %%--------------------------------------------------------------------
  21. -define(Otherwise, true).
  22. -define(COMMON_SHARD, emqx_common_shard).
  23. -define(SHARED_SUB_SHARD, emqx_shared_sub_shard).
  24. -define(MOD_DELAYED_SHARD, emqx_delayed_shard).
  25. %%--------------------------------------------------------------------
  26. %% Banner
  27. %%--------------------------------------------------------------------
  28. -define(PROTOCOL_VERSION, "MQTT/5.0").
  29. -define(ERTS_MINIMUM_REQUIRED, "10.0").
  30. %%--------------------------------------------------------------------
  31. %% Configs
  32. %%--------------------------------------------------------------------
  33. -define(NO_PRIORITY_TABLE, none).
  34. %%--------------------------------------------------------------------
  35. %% Topics' prefix: $SYS | $queue | $share
  36. %%--------------------------------------------------------------------
  37. %% System topic
  38. -define(SYSTOP, <<"$SYS/">>).
  39. %% Queue topic
  40. -define(QUEUE, <<"$queue/">>).
  41. %%--------------------------------------------------------------------
  42. %% Message and Delivery
  43. %%--------------------------------------------------------------------
  44. -record(subscription, {topic, subid, subopts}).
  45. %% See 'Application Message' in MQTT Version 5.0
  46. -record(message, {
  47. %% Global unique message ID
  48. id :: binary(),
  49. %% Message QoS
  50. qos = 0,
  51. %% Message from
  52. from :: atom() | binary(),
  53. %% Message flags
  54. flags = #{} :: emqx_types:flags(),
  55. %% Message headers. May contain any metadata. e.g. the
  56. %% protocol version number, username, peerhost or
  57. %% the PUBLISH properties (MQTT 5.0).
  58. headers = #{} :: emqx_types:headers(),
  59. %% Topic that the message is published to
  60. topic :: emqx_types:topic(),
  61. %% Message Payload
  62. payload :: emqx_types:payload(),
  63. %% Timestamp (Unit: millisecond)
  64. timestamp :: integer()
  65. }).
  66. -record(delivery, {
  67. sender :: pid(), %% Sender of the delivery
  68. message :: #message{} %% The message delivered
  69. }).
  70. %%--------------------------------------------------------------------
  71. %% Route
  72. %%--------------------------------------------------------------------
  73. -define(ROUTE_SHARD, route_shard).
  74. -define(RULE_ENGINE_SHARD, emqx_rule_engine_shard).
  75. -record(route, {
  76. topic :: binary(),
  77. dest :: node() | {binary(), node()}
  78. }).
  79. %%--------------------------------------------------------------------
  80. %% Plugin
  81. %%--------------------------------------------------------------------
  82. -record(plugin, {
  83. name :: atom(),
  84. dir :: string() | undefined,
  85. descr :: string(),
  86. vendor :: string() | undefined,
  87. active = false :: boolean(),
  88. info = #{} :: map()
  89. }).
  90. %%--------------------------------------------------------------------
  91. %% Command
  92. %%--------------------------------------------------------------------
  93. -record(command, {
  94. name :: atom(),
  95. action :: atom(),
  96. args = [] :: list(),
  97. opts = [] :: list(),
  98. usage :: string(),
  99. descr :: string()
  100. }).
  101. %%--------------------------------------------------------------------
  102. %% Banned
  103. %%--------------------------------------------------------------------
  104. -record(banned, {
  105. who :: {clientid, binary()}
  106. | {peerhost, inet:ip_address()}
  107. | {username, binary()}
  108. | {ip_address, inet:ip_address()},
  109. by :: binary(),
  110. reason :: binary(),
  111. at :: integer(),
  112. until :: integer()
  113. }).
  114. -endif.