pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] sijie commented on a change in pull request #2653: Access function state by rest endpoint
Date Wed, 26 Sep 2018 06:01:02 GMT
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

Mime
View raw message