Просмотр исходного кода

fix(resource): fix `query_mode/0` type and usage

Thales Macedo Garitezi 2 лет назад
Родитель
Сommit
7f850f7499

+ 1 - 1
apps/emqx_resource/include/emqx_resource.hrl

@@ -22,7 +22,7 @@
 -type resource_state() :: term().
 -type resource_status() :: connected | disconnected | connecting | stopped.
 -type callback_mode() :: always_sync | async_if_possible.
--type query_mode() :: async | sync | simple_async | simple_sync | dynamic.
+-type query_mode() :: simple_sync | simple_async | sync | async | no_queries.
 -type result() :: term().
 -type reply_fun() :: {fun((result(), Args :: term()) -> any()), Args :: term()} | undefined.
 -type query_opts() :: #{

+ 3 - 5
apps/emqx_resource/src/emqx_resource.erl

@@ -122,6 +122,7 @@
 -export([apply_reply_fun/2]).
 
 -export_type([
+    query_mode/0,
     resource_id/0,
     resource_data/0,
     resource_status/0
@@ -174,8 +175,7 @@
     | {resource_status(), resource_state()}
     | {resource_status(), resource_state(), term()}.
 
--callback query_mode(Config :: term()) ->
-    simple_sync | simple_async | sync | async | no_queries.
+-callback query_mode(Config :: term()) -> query_mode().
 
 -spec list_types() -> [module()].
 list_types() ->
@@ -413,9 +413,7 @@ call_stop(ResId, Mod, ResourceState) ->
         Res
     end).
 
--spec query_mode(module(), term(), creation_opts()) ->
-    simple_sync | simple_async | sync | async | no_queries.
-
+-spec query_mode(module(), term(), creation_opts()) -> query_mode().
 query_mode(Mod, Config, Opts) ->
     case erlang:function_exported(Mod, query_mode, 1) of
         true ->