You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/09/23 10:06:50 UTC

[incubator-eventmesh] branch eventmesh-filters updated: [ISSUE #1382] Add EventMesh Filter interfaces

This is an automated email from the ASF dual-hosted git repository.

mikexue pushed a commit to branch eventmesh-filters
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git


The following commit(s) were added to refs/heads/eventmesh-filters by this push:
     new 19fc8a4e [ISSUE #1382] Add EventMesh Filter interfaces
     new bc5ece4b Merge pull request #1383 from xwm1992/eventmesh-filter
19fc8a4e is described below

commit 19fc8a4ef5f237523b1fc7f8627e5978600fa1d1
Author: xwm1992 <mi...@126.com>
AuthorDate: Fri Sep 23 17:58:20 2022 +0800

    [ISSUE #1382] Add EventMesh Filter interfaces
---
 .../eventmesh/filter/api/EventMeshFilter.java      | 37 ++++++++++++++++++++++
 .../eventmesh/filter/api/FilterRegistry.java       | 23 ++++++++++++++
 .../apache/eventmesh/filter/api/FilterRunner.java  | 26 +++++++++++++++
 .../filter/api/factory/FilterFactory.java          | 25 +++++++++++++++
 .../eventmesh/filter/api/loader/FilterLoader.java  | 34 ++++++++++++++++++++
 5 files changed, 145 insertions(+)

diff --git a/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/EventMeshFilter.java b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/EventMeshFilter.java
new file mode 100644
index 00000000..b04f99d0
--- /dev/null
+++ b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/EventMeshFilter.java
@@ -0,0 +1,37 @@
+/*
+ * 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.filter.api;
+
+import org.apache.eventmesh.spi.EventMeshExtensionType;
+import org.apache.eventmesh.spi.EventMeshSPI;
+
+import io.cloudevents.CloudEvent;
+
+@EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.FILTER)
+public interface EventMeshFilter<I extends CloudEvent, O extends CloudEvent> {
+
+    boolean isDisabled();
+
+    int filterOrder();
+
+    String filterName();
+
+    FilterType filterType();
+
+    O apply(I input);
+}
diff --git a/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/FilterRegistry.java b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/FilterRegistry.java
new file mode 100644
index 00000000..9f5405ea
--- /dev/null
+++ b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/FilterRegistry.java
@@ -0,0 +1,23 @@
+/*
+ * 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.filter.api;
+
+public interface FilterRegistry {
+
+    // todo: integrate with registry
+}
diff --git a/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/FilterRunner.java b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/FilterRunner.java
new file mode 100644
index 00000000..df851f0b
--- /dev/null
+++ b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/FilterRunner.java
@@ -0,0 +1,26 @@
+/*
+ * 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.filter.api;
+
+import io.cloudevents.CloudEvent;
+
+public interface FilterRunner<I extends CloudEvent> {
+
+    I filter(I cloudevents);
+
+}
diff --git a/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/factory/FilterFactory.java b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/factory/FilterFactory.java
new file mode 100644
index 00000000..8e2af766
--- /dev/null
+++ b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/factory/FilterFactory.java
@@ -0,0 +1,25 @@
+/*
+ * 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.filter.api.factory;
+
+import org.apache.eventmesh.filter.api.EventMeshFilter;
+
+public interface FilterFactory {
+
+    EventMeshFilter getMeshFilter(String filterName);
+}
diff --git a/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/loader/FilterLoader.java b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/loader/FilterLoader.java
new file mode 100644
index 00000000..03180222
--- /dev/null
+++ b/eventmesh-filter-plugin/eventmesh-filter-api/src/main/java/org/apache/eventmesh/filter/api/loader/FilterLoader.java
@@ -0,0 +1,34 @@
+/*
+ * 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.filter.api.loader;
+
+import org.apache.eventmesh.filter.api.EventMeshFilter;
+import org.apache.eventmesh.filter.api.FilterType;
+
+import java.util.Comparator;
+import java.util.SortedSet;
+
+import io.cloudevents.CloudEvent;
+
+public interface FilterLoader {
+
+    Comparator<EventMeshFilter<?, ?>> FILTER_COMPARATOR =
+        Comparator.<EventMeshFilter<?, ?>>comparingInt(EventMeshFilter::filterOrder).thenComparing(EventMeshFilter::filterName);
+
+    SortedSet<EventMeshFilter<?,?>> getFiltersByType(FilterType filterType);
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org