Quellcode durchsuchen

refactor(gcp_pubsub): always cleanup resources when calling `on_stop`

Fixes https://emqx.atlassian.net/browse/EMQX-9934

The way that this connector was structured already depended only on the resource ID.  This
PR just makes it completely independent of the resource state term, and also treats an
already absent pool as a success when stopping it.
Thales Macedo Garitezi vor 2 Jahren
Ursprung
Commit
d9aac63f82
1 geänderte Dateien mit 11 neuen und 7 gelöschten Zeilen
  1. 11 7
      apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_connector.erl

+ 11 - 7
apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_connector.erl

@@ -134,17 +134,21 @@ on_start(
     end.
     end.
 
 
 -spec on_stop(resource_id(), state()) -> ok | {error, term()}.
 -spec on_stop(resource_id(), state()) -> ok | {error, term()}.
-on_stop(
-    ResourceId,
-    _State = #{jwt_config := JWTConfig}
-) ->
-    ?tp(gcp_pubsub_stop, #{resource_id => ResourceId, jwt_config => JWTConfig}),
+on_stop(ResourceId, _State) ->
+    ?tp(gcp_pubsub_stop, #{resource_id => ResourceId}),
     ?SLOG(info, #{
     ?SLOG(info, #{
         msg => "stopping_gcp_pubsub_bridge",
         msg => "stopping_gcp_pubsub_bridge",
         connector => ResourceId
         connector => ResourceId
     }),
     }),
-    emqx_connector_jwt:delete_jwt(?JWT_TABLE, ResourceId),
-    ehttpc_sup:stop_pool(ResourceId).
+    ok = emqx_connector_jwt:delete_jwt(?JWT_TABLE, ResourceId),
+    case ehttpc_sup:stop_pool(ResourceId) of
+        ok ->
+            ok;
+        {error, not_found} ->
+            ok;
+        Error ->
+            Error
+    end.
 
 
 -spec on_query(
 -spec on_query(
     resource_id(),
     resource_id(),