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

docs: note that connector state must be immutable to avoid errors

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

+ 3 - 0
apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_consumer_worker.erl

@@ -141,6 +141,9 @@ connect(Opts0) ->
     {Topic, MQTTConfig} = lists:nth(Index, TopicMappingList),
     {Topic, MQTTConfig} = lists:nth(Index, TopicMappingList),
     Config = #{
     Config = #{
         ack_retry_interval => AckRetryInterval,
         ack_retry_interval => AckRetryInterval,
+        %% Note: the `connector_state' value here must be immutable and not changed by the
+        %% bridge during `on_get_status', since we have handed it over to the pull
+        %% workers.
         connector_state => ConnectorState,
         connector_state => ConnectorState,
         hookpoint => Hookpoint,
         hookpoint => Hookpoint,
         instance_id => InstanceId,
         instance_id => InstanceId,

+ 2 - 0
apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_impl_consumer.erl

@@ -69,6 +69,8 @@ on_stop(InstanceId, undefined = _State) ->
 
 
 -spec on_get_status(resource_id(), state()) -> connected | disconnected.
 -spec on_get_status(resource_id(), state()) -> connected | disconnected.
 on_get_status(InstanceId, _State) ->
 on_get_status(InstanceId, _State) ->
+    %% Note: do *not* alter the `connector_state' value here.  It must be immutable, since
+    %% we have handed it over to the pull workers.
     case
     case
         emqx_resource_pool:health_check_workers(
         emqx_resource_pool:health_check_workers(
             InstanceId,
             InstanceId,