pandaapo commented on code in PR #4578:
URL: https://github.com/apache/eventmesh/pull/4578#discussion_r1404359357


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/FilterEngine.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * 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.eventmesh.runtime.boot;
+
+import org.apache.eventmesh.api.meta.MetaServiceListener;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.common.utils.LogUtils;
+import org.apache.eventmesh.filter.pattern.Pattern;
+import org.apache.eventmesh.filter.patternbuild.PatternBuilder;
+import 
org.apache.eventmesh.runtime.core.protocol.http.consumer.ConsumerGroupManager;
+import 
org.apache.eventmesh.runtime.core.protocol.http.consumer.ConsumerManager;
+import org.apache.eventmesh.runtime.core.protocol.producer.EventMeshProducer;
+import org.apache.eventmesh.runtime.core.protocol.producer.ProducerManager;
+import org.apache.eventmesh.runtime.meta.MetaStorage;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class FilterEngine {
+
+    /**
+     * key:group-topic
+     **/
+    private final Map<String, Pattern> filterPatternMap = new HashMap<>();
+
+    private final String filterPrefix = "filter-";
+
+    private final MetaStorage metaStorage;
+
+    private MetaServiceListener metaServiceListener;
+
+    private final ProducerManager producerManager;
+
+    private final ConsumerManager consumerManager;
+
+    private final ScheduledExecutorService scheduledExecutorService = 
Executors.newSingleThreadScheduledExecutor();
+
+    public FilterEngine(MetaStorage metaStorage, ProducerManager 
producerManager, ConsumerManager consumerManager) {
+        this.metaStorage = metaStorage;
+        this.producerManager = producerManager;
+        this.consumerManager = consumerManager;
+    }
+
+    public void start() {
+        Map<String, String> filterMetaData = 
metaStorage.getMetaData(filterPrefix, true);
+        for (Entry<String, String> filterDataEntry : 
filterMetaData.entrySet()) {
+            // filter-group
+            String key = filterDataEntry.getKey();
+            // topic-filterRule list
+            String value = filterDataEntry.getValue();
+            updateFilterPatternMap(key, value);
+        }
+        metaServiceListener = this::updateFilterPatternMap;
+
+        // addListeners for producerManager & consumerManager
+        scheduledExecutorService.scheduleAtFixedRate(() -> {

Review Comment:
   Could you add another task to pull the rule configuration from the remote 
configuration center, so that we can obtain the new rules?
   
   这里面是不是还可以再增加一个任务,去拉取远程配置中心的规则配置,这样可以获取新增的规则?



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