pefernan commented on code in PR #2814:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2814#discussion_r1889180400


##########
packages/jbpm-quarkus-devui/jbpm-quarkus-devui-runtime/src/main/java/org/jbpm/quarkus/devui/runtime/rpc/DataIndexCounter.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.jbpm.quarkus.devui.runtime.rpc;
+
+import io.smallrye.mutiny.Multi;
+import io.smallrye.mutiny.subscription.MultiEmitter;
+import io.vertx.core.Future;
+import io.vertx.core.Vertx;
+import io.vertx.core.json.JsonObject;
+import io.vertx.ext.web.client.WebClient;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataIndexCounter {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(DataIndexCounter.class);
+    private final Vertx vertx;
+    private final Multi<String> multi;
+    private final WebClient dataIndexWebClient;
+
+    private String query;
+    private String field;
+    private String count = "-";
+    private MultiEmitter<? super String> emitter;
+    private long vertxTimer;
+
+    public DataIndexCounter(String query, String graphField, WebClient 
dataIndexWebClient) {
+        if (dataIndexWebClient == null) {
+            throw new IllegalArgumentException("dataIndexWebClient is null");
+        }
+        this.query = query;
+        this.field = graphField;
+        this.dataIndexWebClient = dataIndexWebClient;
+        this.vertx = Vertx.vertx();
+
+        this.multi = Multi.createFrom().emitter(emitter -> {
+            this.emitter = emitter;
+            vertxTimer = vertx.setPeriodic(500, id -> {
+                this.emit();
+            });
+            this.emit();
+        });
+        refreshCount();
+    }
+
+    public void refresh() {
+        vertx.setTimer(500, id -> {

Review Comment:
   This timer looks like to short, in slow laptops (like main) this may not 
work, but I think we can go with it for now.



##########
packages/jbpm-quarkus-devui/jbpm-quarkus-devui-runtime/src/main/java/org/jbpm/quarkus/devui/runtime/rpc/JBPMDevUIEventPublisher.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.jbpm.quarkus.devui.runtime.rpc;
+
+import jakarta.enterprise.context.ApplicationScoped;
+
+import org.kie.kogito.event.DataEvent;
+import org.kie.kogito.event.EventPublisher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.quarkus.arc.profile.IfBuildProfile;
+
+import java.util.Collection;
+import java.util.Objects;
+
+@ApplicationScoped
+@IfBuildProfile("dev")
+public class JBPMDevUIEventPublisher implements EventPublisher {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(JBPMDevUIEventPublisher.class);
+    private Runnable onProcessEvent;
+    private Runnable onTaskEvent;
+    private Runnable onJobEvent;
+
+    @Override
+    public void publish(DataEvent<?> event) {
+        switch (event.getType()) {
+            case "ProcessInstanceStateDataEvent":
+                maybeRun(onProcessEvent);
+                break;
+            case "UserTaskInstanceStateDataEvent":
+                maybeRun(onTaskEvent);
+                break;
+            case "JobEvent":
+                maybeRun(onJobEvent);
+                break;
+            default:

Review Comment:
   maybe we can get rid of the default



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to