emqx_resource_runtime.hrl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2024 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_RESOURCE_RUNTIME_HRL).
  17. -define(EMQX_RESOURCE_RUNTIME_HRL, true).
  18. -include("emqx_resource.hrl").
  19. -define(NO_CHANNEL, no_channel).
  20. %% status and error, cached in ets for each connector
  21. -type st_err() :: #{
  22. status := resource_status(),
  23. error := term()
  24. }.
  25. %% the relatively stable part to be cached in persistent_term for each connector
  26. -type cb() :: #{
  27. mod := module(),
  28. callback_mode := callback_mode(),
  29. query_mode := query_mode(),
  30. state := term()
  31. }.
  32. %% the rutime context to be used for each channel
  33. -record(rt, {
  34. st_err :: st_err(),
  35. cb :: cb(),
  36. channel_status :: ?NO_CHANNEL | channel_status()
  37. }).
  38. -type runtime() :: #rt{}.
  39. -endif.