Skip to content

Commit 7b90624

Browse files
committed
Refactor: Migrate v2 runtime components to main runtime and update function APIs
1 parent 1649391 commit 7b90624

File tree

49 files changed

+342
-725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+342
-725
lines changed

eventmesh-common/src/main/java/org/apache/eventmesh/common/enums/ComponentType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
public enum ComponentType {
2121
CONNECTOR("connector"),
2222
FUNCTION("function"),
23+
ROUTER("router"),
2324
MESH("mesh");
2425

2526
public String name;

eventmesh-function/eventmesh-function-api/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
18+
dependencies {
19+
implementation project(":eventmesh-common")
20+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.function.api;
19+
20+
import org.apache.eventmesh.common.exception.EventMeshException;
21+
22+
/**
23+
* EventMesh router interface, used to route messages to different topics or destinations.
24+
*/
25+
public interface Router extends EventMeshFunction<String, String> {
26+
27+
String route(String json);
28+
29+
@Override
30+
default String apply(String content) {
31+
try {
32+
return route(content);
33+
} catch (Exception e) {
34+
throw new EventMeshException("Failed to route content", e);
35+
}
36+
}
37+
38+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
dependencies {
19+
implementation project(":eventmesh-function:eventmesh-function-api")
20+
implementation project(":eventmesh-common")
21+
22+
testImplementation 'org.junit.jupiter:junit-jupiter-api'
23+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
24+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.function.router;
19+
20+
import org.apache.eventmesh.function.api.Router;
21+
22+
public class RouterBuilder {
23+
24+
public static Router build(String routerConfig) {
25+
return new DefaultRouter(routerConfig);
26+
}
27+
28+
private static class DefaultRouter implements Router {
29+
private final String targetTopic;
30+
31+
public DefaultRouter(String targetTopic) {
32+
this.targetTopic = targetTopic;
33+
}
34+
35+
@Override
36+
public String route(String json) {
37+
return targetTopic;
38+
}
39+
}
40+
}

eventmesh-runtime-v2/bin/start-v2.sh

Lines changed: 0 additions & 200 deletions
This file was deleted.

0 commit comments

Comments
 (0)