mcgilman commented on code in PR #11231:
URL: https://github.com/apache/nifi/pull/11231#discussion_r3219867936


##########
nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/components/connector/ConnectorRepository.java:
##########
@@ -89,16 +89,26 @@ public interface ConnectorRepository {
     void removeConnector(String connectorId);
 
     /**
-     * Gets the Connector with the given identifier
+     * Gets the Connector with the given identifier.
+     *
      * @param identifier the identifier of the Connector to get
+     * @param syncMode whether to consult the {@link 
ConnectorConfigurationProvider} (if configured)
+     *                 to refresh local state from the external store before 
returning, or whether
+     *                 to return the in-memory copy as-is. See {@link 
ConnectorSyncMode}.
      * @return the Connector with the given identifier, or null if no such 
Connector exists
      */
-    ConnectorNode getConnector(String identifier);
+    ConnectorNode getConnector(String identifier, ConnectorSyncMode syncMode);

Review Comment:
   Do these changes need to be introduced in a manner that maintains backwards 
capability?



##########
nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/components/connector/ConnectorSyncMode.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.components.connector;
+
+/**
+ * Indicates whether retrieval of {@link ConnectorNode} instances from the
+ * {@link ConnectorRepository} should consult the configured
+ * {@link ConnectorConfigurationProvider} to refresh the local state from the
+ * external store, or whether the in-memory copy should be returned as-is.
+ *
+ * <p>Choosing {@link #SYNC_WITH_PROVIDER} causes the repository to call into
+ * the configuration provider (which may perform network I/O, secret lookups,
+ * and other potentially expensive or failure-prone operations) before 
returning
+ * the connector. This is appropriate for user-facing reads that must reflect
+ * the latest external state, such as REST API responses. Callers operating on
+ * critical paths that must not block on or fail because of the external store
+ * (for example, periodic flow serialization) should use {@link #LOCAL_ONLY}
+ * instead.</p>
+ */
+public enum ConnectorSyncMode {
+
+    /**
+     * Consult the {@link ConnectorConfigurationProvider} (when configured) to
+     * refresh the local connector state from the external store before
+     * returning. This may perform network I/O and may throw if the external
+     * store is unavailable.
+     */
+    SYNC_WITH_PROVIDER,
+
+    /**
+     * Return the in-memory connector state without consulting the
+     * {@link ConnectorConfigurationProvider}. No external I/O is performed.
+     */
+    LOCAL_ONLY

Review Comment:
   Can we also update `StandardAuthorizableLookup` to invoke `getConnector` 
with `LOCAL_ONLY`?



##########
nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/components/connector/ConnectorRepository.java:
##########
@@ -89,16 +89,26 @@ public interface ConnectorRepository {
     void removeConnector(String connectorId);
 
     /**
-     * Gets the Connector with the given identifier
+     * Gets the Connector with the given identifier.
+     *
      * @param identifier the identifier of the Connector to get
+     * @param syncMode whether to consult the {@link 
ConnectorConfigurationProvider} (if configured)
+     *                 to refresh local state from the external store before 
returning, or whether
+     *                 to return the in-memory copy as-is. See {@link 
ConnectorSyncMode}.
      * @return the Connector with the given identifier, or null if no such 
Connector exists
      */
-    ConnectorNode getConnector(String identifier);
+    ConnectorNode getConnector(String identifier, ConnectorSyncMode syncMode);
 
     /**
+     * Returns all Connectors in the Repository.
+     *
+     * @param syncMode whether to consult the {@link 
ConnectorConfigurationProvider} (if configured)
+     *                 to refresh each connector's local state from the 
external store before
+     *                 returning, or whether to return the in-memory copies 
as-is. See
+     *                 {@link ConnectorSyncMode}.
      * @return all Connectors in the Repository
      */
-    List<ConnectorNode> getConnectors();
+    List<ConnectorNode> getConnectors(ConnectorSyncMode syncMode);

Review Comment:
   Do these changes need to be introduced in a manner that maintains backwards 
capability?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to