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

chore: use macros for connector and action status atoms

Kjell Winblad 2 лет назад
Родитель
Сommit
cfad0923cf
1 измененных файлов с 13 добавлено и 11 удалено
  1. 13 11
      apps/emqx_bridge_kinesis/src/emqx_bridge_kinesis_impl_producer.erl

+ 13 - 11
apps/emqx_bridge_kinesis/src/emqx_bridge_kinesis_impl_producer.erl

@@ -88,7 +88,9 @@ on_stop(InstanceId, _State) ->
     emqx_resource_pool:stop(InstanceId).
     emqx_resource_pool:stop(InstanceId).
 
 
 -spec on_get_status(resource_id(), state()) ->
 -spec on_get_status(resource_id(), state()) ->
-    connected | disconnected | {disconnected, state(), {unhealthy_target, string()}}.
+    ?status_connected
+    | ?status_disconnected
+    | {?status_disconnected, state(), {unhealthy_target, string()}}.
 on_get_status(_InstanceId, #{pool_name := Pool} = State) ->
 on_get_status(_InstanceId, #{pool_name := Pool} = State) ->
     case
     case
         emqx_resource_pool:health_check_workers(
         emqx_resource_pool:health_check_workers(
@@ -99,15 +101,15 @@ on_get_status(_InstanceId, #{pool_name := Pool} = State) ->
         )
         )
     of
     of
         {ok, Values} ->
         {ok, Values} ->
-            AllOk = lists:all(fun(S) -> S =:= {ok, connected} end, Values),
+            AllOk = lists:all(fun(S) -> S =:= {ok, ?status_connected} end, Values),
             case AllOk of
             case AllOk of
                 true ->
                 true ->
-                    connected;
+                    ?status_connected;
                 false ->
                 false ->
                     Unhealthy = lists:any(fun(S) -> S =:= {error, unhealthy_target} end, Values),
                     Unhealthy = lists:any(fun(S) -> S =:= {error, unhealthy_target} end, Values),
                     case Unhealthy of
                     case Unhealthy of
-                        true -> {disconnected, State, {unhealthy_target, ?TOPIC_MESSAGE}};
-                        false -> disconnected
+                        true -> {?status_disconnected, State, {unhealthy_target, ?TOPIC_MESSAGE}};
+                        false -> ?status_disconnected
                     end
                     end
             end;
             end;
         {error, Reason} ->
         {error, Reason} ->
@@ -116,7 +118,7 @@ on_get_status(_InstanceId, #{pool_name := Pool} = State) ->
                 state => State,
                 state => State,
                 reason => Reason
                 reason => Reason
             }),
             }),
-            disconnected
+            ?status_disconnected
     end.
     end.
 
 
 on_add_channel(
 on_add_channel(
@@ -176,15 +178,15 @@ on_get_channel_status(
         )
         )
     of
     of
         {ok, Values} ->
         {ok, Values} ->
-            AllOk = lists:all(fun(S) -> S =:= {ok, connected} end, Values),
+            AllOk = lists:all(fun(S) -> S =:= {ok, ?status_connected} end, Values),
             case AllOk of
             case AllOk of
                 true ->
                 true ->
-                    connected;
+                    ?status_connected;
                 false ->
                 false ->
                     Unhealthy = lists:any(fun(S) -> S =:= {error, unhealthy_target} end, Values),
                     Unhealthy = lists:any(fun(S) -> S =:= {error, unhealthy_target} end, Values),
                     case Unhealthy of
                     case Unhealthy of
-                        true -> {disconnected, {unhealthy_target, ?TOPIC_MESSAGE}};
-                        false -> disconnected
+                        true -> {?status_disconnected, {unhealthy_target, ?TOPIC_MESSAGE}};
+                        false -> ?status_disconnected
                     end
                     end
             end;
             end;
         {error, Reason} ->
         {error, Reason} ->
@@ -193,7 +195,7 @@ on_get_channel_status(
                 state => State,
                 state => State,
                 reason => Reason
                 reason => Reason
             }),
             }),
-            disconnected
+            ?status_disconnected
     end.
     end.
 
 
 on_get_channels(ResId) ->
 on_get_channels(ResId) ->