You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/20 13:16:52 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

eolivelli commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r560949520



##########
File path: pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/Context.java
##########
@@ -262,6 +264,21 @@
      */
     String getSecret(String secretName);
 
+    /**
+     * Get the pulsar admin client.
+     *
+     * @return The instance of pulsar admin client
+     */
+    PulsarAdmin getPulsarAdmin();
+
+    /**
+     * Get the pulsar admin client by cluster name.

Review comment:
       can we explain here when it is better to use this method instead of the other ?

##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java
##########
@@ -300,6 +304,21 @@ public String getSecret(String secretName) {
         }
     }
 
+    @Override
+    public PulsarAdmin getPulsarAdmin() {
+        return getPulsarAdmin(defaultPulsarCluster);
+    }
+
+    @Override
+    public PulsarAdmin getPulsarAdmin(String clusterName) {
+        PulsarCluster pulsarCluster = externalPulsarClusters.get(clusterName);
+        if (pulsarCluster != null) {
+            return pulsarCluster.getAdminClient();
+        } else {
+            return null;

Review comment:
       shall we throw an error ? maybe reporting the list of known clusters ?
   `
   throw new IllegalArgumentException("PulsarAdmin for cluster "+clusterName+" is not available, only "+extrenalPulsarCluters.keySet())` 
   
   if we do not throw an error, can we log something at warning level ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org