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 2018/09/26 06:01:02 UTC

[GitHub] sijie commented on a change in pull request #2653: Access function state by rest endpoint

sijie commented on a change in pull request #2653: Access function state by rest endpoint
URL: https://github.com/apache/pulsar/pull/2653#discussion_r220434184
 
 

 ##########
 File path: pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
 ##########
 @@ -666,6 +676,65 @@ public Response triggerFunction(final String tenant, final String namespace, fin
         }
     }
 
+    public Response getFunctionState(final String tenant, final String namespace,
+                                     final String functionName, final String key) {
+        if (!isWorkerServiceAvailable()) {
+            return getUnavailableResponse();
+        }
+
+        // validate parameters
+        try {
+            validateGetFunctionStateParams(tenant, namespace, functionName, key);
+        } catch (IllegalArgumentException e) {
+            log.error("Invalid getFunctionState request @ /{}/{}/{}/{}",
+                tenant, namespace, functionName, key, e);
+            return Response.status(Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON)
+                .entity(new ErrorData(e.getMessage())).build();
+        }
+
+        String tableNs = String.format(
+            "%s_%s",
+            tenant,
+            namespace).replace('-', '_');
+        String tableName = functionName;
+
+        String stateStorageServiceUrl = worker().getWorkerConfig().getStateStorageServiceUrl();
+
+        try (StorageClient client = StorageClientBuilder.newBuilder()
 
 Review comment:
   actually it might be good to optimize the storage client interface, so we are able to cache the client in worker. and we don't need to initialize the client for each rest call. can you file an issue for that and work on it?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services