emqx.hrl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. %%--------------------------------------------------------------------
  23. %% Banner
  24. %%--------------------------------------------------------------------
  25. -define(PROTOCOL_VERSION, "MQTT/5.0").
  26. -define(ERTS_MINIMUM_REQUIRED, "10.0").
  27. %%--------------------------------------------------------------------
  28. %% Configs
  29. %%--------------------------------------------------------------------
  30. -define(NO_PRIORITY_TABLE, none).
  31. %%--------------------------------------------------------------------
  32. %% Topics' prefix: $SYS | $queue | $share
  33. %%--------------------------------------------------------------------
  34. %% System topic
  35. -define(SYSTOP, <<"$SYS/">>).
  36. %% Queue topic
  37. -define(QUEUE, <<"$queue/">>).
  38. %%--------------------------------------------------------------------
  39. %% Message and Delivery
  40. %%--------------------------------------------------------------------
  41. -record(subscription, {topic, subid, subopts}).
  42. %% See 'Application Message' in MQTT Version 5.0
  43. -record(message, {
  44. %% Global unique message ID
  45. id :: binary(),
  46. %% Message QoS
  47. qos = 0,
  48. %% Message from
  49. from :: atom() | binary(),
  50. %% Message flags
  51. flags = #{} :: emqx_types:flags(),
  52. %% Message headers. May contain any metadata. e.g. the
  53. %% protocol version number, username, peerhost or
  54. %% the PUBLISH properties (MQTT 5.0).
  55. headers = #{} :: emqx_types:headers(),
  56. %% Topic that the message is published to
  57. topic :: emqx_types:topic(),
  58. %% Message Payload
  59. payload :: emqx_types:payload(),
  60. %% Timestamp (Unit: millisecond)
  61. timestamp :: integer()
  62. }).
  63. -record(delivery, {
  64. sender :: pid(), %% Sender of the delivery
  65. message :: #message{} %% The message delivered
  66. }).
  67. %%--------------------------------------------------------------------
  68. %% Route
  69. %%--------------------------------------------------------------------
  70. -record(route, {
  71. topic :: binary(),
  72. dest :: node() | {binary(), node()}
  73. }).
  74. %%--------------------------------------------------------------------
  75. %% Plugin
  76. %%--------------------------------------------------------------------
  77. -record(plugin, {
  78. name :: atom(),
  79. dir :: string() | undefined,
  80. descr :: string(),
  81. vendor :: string() | undefined,
  82. active = false :: boolean(),
  83. info = #{} :: map(),
  84. type :: atom()
  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 :: {clientid, binary()}
  102. | {peerhost, inet:ip_address()}
  103. | {username, binary()}
  104. | {ip_address, inet:ip_address()},
  105. by :: binary(),
  106. reason :: binary(),
  107. at :: integer(),
  108. until :: integer()
  109. }).
  110. -endif.