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

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


The following commit(s) were added to refs/heads/master by this push:
     new da0276587 [ISSUE #4277] Add eventmesh-connector-knative (#4428)
da0276587 is described below

commit da0276587d3597c2dfe9aa53edf4d28a8e5c345f
Author: Fabian Bao <[email protected]>
AuthorDate: Wed Sep 6 13:03:20 2023 +0800

    [ISSUE #4277] Add eventmesh-connector-knative (#4428)
    
    * feat: add eventmesh-connector-knative.
    
    * feat: add eventmesh-connector-knative.
    
    * feat: add eventmesh-connector-knative.
    
    * feat: add eventmesh-connector-knative.
    
    * feat: add eventmesh-connector-knative.
    
    * feat: add eventmesh-connector-knative.
---
 .../eventmesh-connector-knative/build.gradle       |  33 ++++++
 .../eventmesh-connector-knative/gradle.properties  |  18 ++++
 .../knative/cloudevent/KnativeHeaders.java         |  31 ++++++
 .../knative/cloudevent/KnativeMessageFactory.java  |  40 +++++++
 .../knative/config/KnativeServerConfig.java        |  32 ++++++
 .../knative/server/KnativeConnectServer.java       |  46 ++++++++
 .../knative/sink/config/KnativeSinkConfig.java     |  31 ++++++
 .../knative/sink/config/SinkConnectorConfig.java   |  31 ++++++
 .../sink/connector/KnativeSinkConnector.java       | 117 +++++++++++++++++++++
 .../knative/source/config/KnativeSourceConfig.java |  31 ++++++
 .../source/config/SourceConnectorConfig.java       |  31 ++++++
 .../source/connector/KnativeSourceConnector.java   |  79 ++++++++++++++
 .../src/main/resources/server-config.yml           |  19 ++++
 .../src/main/resources/sink-config.yml             |  31 ++++++
 .../src/main/resources/source-config.yml           |  39 +++++++
 settings.gradle                                    |   5 +-
 16 files changed, 612 insertions(+), 2 deletions(-)

diff --git a/eventmesh-connectors/eventmesh-connector-knative/build.gradle 
b/eventmesh-connectors/eventmesh-connector-knative/build.gradle
new file mode 100644
index 000000000..2380a6b19
--- /dev/null
+++ b/eventmesh-connectors/eventmesh-connector-knative/build.gradle
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+configurations {
+    implementation.exclude group: 'ch.qos.logback', module: 'logback-classic'
+    implementation.exclude group: 'log4j', module: 'log4j'
+}
+
+dependencies {
+    api project(":eventmesh-openconnect:eventmesh-openconnect-java")
+    implementation project(":eventmesh-common")
+
+    implementation 'org.asynchttpclient:async-http-client'
+
+    implementation 'io.cloudevents:cloudevents-json-jackson'
+
+    compileOnly 'org.projectlombok:lombok'
+    annotationProcessor 'org.projectlombok:lombok'
+}
diff --git a/eventmesh-connectors/eventmesh-connector-knative/gradle.properties 
b/eventmesh-connectors/eventmesh-connector-knative/gradle.properties
new file mode 100644
index 000000000..12ce2c698
--- /dev/null
+++ b/eventmesh-connectors/eventmesh-connector-knative/gradle.properties
@@ -0,0 +1,18 @@
+# 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.
+#
+knative_version=1.5
+pluginType=connector
+pluginName=pravega
\ No newline at end of file
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/cloudevent/KnativeHeaders.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/cloudevent/KnativeHeaders.java
new file mode 100644
index 000000000..217023dde
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/cloudevent/KnativeHeaders.java
@@ -0,0 +1,31 @@
+/*
+ * 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.connector.knative.cloudevent;
+
+public class KnativeHeaders {
+
+    public static final String CONTENT_TYPE = "Content-Type";
+
+    public static final String CE_ID = "Ce-Id";
+
+    public static final String CE_SPECVERSION = "Ce-Specversion";
+
+    public static final String CE_TYPE = "Ce-Type";
+
+    public static final String CE_SOURCE = "Ce-Source";
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/cloudevent/KnativeMessageFactory.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/cloudevent/KnativeMessageFactory.java
new file mode 100644
index 000000000..d2d82e203
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/cloudevent/KnativeMessageFactory.java
@@ -0,0 +1,40 @@
+/*
+ * 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.connector.knative.cloudevent;
+
+import java.nio.charset.StandardCharsets;
+
+import io.cloudevents.CloudEvent;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public final class KnativeMessageFactory {
+
+    private KnativeMessageFactory() {
+        // prevent instantiation
+    }
+
+    public static String createReader(final CloudEvent message) {
+        if (message.getData() == null) {
+            log.warn("CloudEvent message's data is null.");
+            return "";
+        }
+        return new String(message.getData().toBytes(), StandardCharsets.UTF_8);
+    }
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/config/KnativeServerConfig.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/config/KnativeServerConfig.java
new file mode 100644
index 000000000..4125132ad
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/config/KnativeServerConfig.java
@@ -0,0 +1,32 @@
+/*
+ * 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.connector.knative.config;
+
+import org.apache.eventmesh.openconnect.api.config.Config;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class KnativeServerConfig extends Config {
+
+    private boolean sourceEnable;
+
+    private boolean sinkEnable;
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/server/KnativeConnectServer.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/server/KnativeConnectServer.java
new file mode 100644
index 000000000..108026167
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/server/KnativeConnectServer.java
@@ -0,0 +1,46 @@
+/*
+ * 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.connector.knative.server;
+
+import org.apache.eventmesh.connector.knative.config.KnativeServerConfig;
+import 
org.apache.eventmesh.connector.knative.sink.connector.KnativeSinkConnector;
+import 
org.apache.eventmesh.connector.knative.source.connector.KnativeSourceConnector;
+import org.apache.eventmesh.openconnect.Application;
+import org.apache.eventmesh.openconnect.util.ConfigUtil;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class KnativeConnectServer {
+
+    public static void main(String[] args) throws Exception {
+
+        KnativeServerConfig serverConfig = 
ConfigUtil.parse(KnativeServerConfig.class, "server-config.yml");
+
+        if (serverConfig.isSourceEnable()) {
+            Application knativeSourceApp = new Application();
+            knativeSourceApp.run(KnativeSourceConnector.class);
+        }
+
+        if (serverConfig.isSinkEnable()) {
+            Application knativeSinkApp = new Application();
+            knativeSinkApp.run(KnativeSinkConnector.class);
+        }
+
+    }
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/config/KnativeSinkConfig.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/config/KnativeSinkConfig.java
new file mode 100644
index 000000000..85bb38a90
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/config/KnativeSinkConfig.java
@@ -0,0 +1,31 @@
+/*
+ * 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.connector.knative.sink.config;
+
+import org.apache.eventmesh.openconnect.api.config.SinkConfig;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class KnativeSinkConfig extends SinkConfig {
+
+    public SinkConnectorConfig connectorConfig;
+
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/config/SinkConnectorConfig.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/config/SinkConnectorConfig.java
new file mode 100644
index 000000000..5694c643f
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/config/SinkConnectorConfig.java
@@ -0,0 +1,31 @@
+/*
+ * 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.connector.knative.sink.config;
+
+import lombok.Data;
+
+@Data
+public class SinkConnectorConfig {
+
+    private String connectorName;
+
+    public String emurl;
+
+    public String serviceAddr;
+
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/connector/KnativeSinkConnector.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/connector/KnativeSinkConnector.java
new file mode 100644
index 000000000..d5e757267
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/connector/KnativeSinkConnector.java
@@ -0,0 +1,117 @@
+/*
+ * 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.connector.knative.sink.connector;
+
+import static org.asynchttpclient.Dsl.asyncHttpClient;
+
+import org.apache.eventmesh.connector.knative.cloudevent.KnativeHeaders;
+import org.apache.eventmesh.connector.knative.cloudevent.KnativeMessageFactory;
+import org.apache.eventmesh.connector.knative.sink.config.KnativeSinkConfig;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SinkConnectorContext;
+import org.apache.eventmesh.openconnect.api.sink.Sink;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.asynchttpclient.AsyncHttpClient;
+import org.asynchttpclient.ListenableFuture;
+import org.asynchttpclient.Response;
+import org.asynchttpclient.util.HttpConstants;
+
+import io.cloudevents.CloudEvent;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class KnativeSinkConnector implements Sink {
+
+    private KnativeSinkConfig sinkConfig;
+
+    private transient AsyncHttpClient asyncHttpClient;
+
+    private static final AtomicBoolean started = new AtomicBoolean(false);
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return KnativeSinkConfig.class;
+    }
+
+    @Override
+    public void init(Config config) throws Exception {
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) throws Exception {
+        SinkConnectorContext sinkConnectorContext = (SinkConnectorContext) 
connectorContext;
+        this.sinkConfig = (KnativeSinkConfig) 
sinkConnectorContext.getSinkConfig();
+        this.asyncHttpClient = asyncHttpClient();
+    }
+
+    @Override
+    public void start() throws Exception {
+        started.compareAndSet(false, true);
+    }
+
+    @Override
+    public void commit(ConnectRecord record) {
+
+    }
+
+    @Override
+    public String name() {
+        return this.sinkConfig.getConnectorConfig().getConnectorName();
+    }
+
+    @Override
+    public void stop() {
+        started.compareAndSet(true, false);
+    }
+
+    @Override
+    public void put(List<ConnectRecord> sinkRecords) {
+        for (ConnectRecord connectRecord : sinkRecords) {
+            CloudEvent cloudEvent = 
CloudEventUtil.convertRecordToEvent(connectRecord);
+            try {
+                ListenableFuture<Response> execute = 
asyncHttpClient.preparePost("http://"; + 
sinkConfig.getConnectorConfig().getServiceAddr())
+                        .addHeader(KnativeHeaders.CONTENT_TYPE, 
cloudEvent.getDataContentType())
+                        .addHeader(KnativeHeaders.CE_ID, cloudEvent.getId())
+                        .addHeader(KnativeHeaders.CE_SPECVERSION, 
String.valueOf(cloudEvent.getSpecVersion()))
+                        .addHeader(KnativeHeaders.CE_TYPE, 
cloudEvent.getType())
+                        .addHeader(KnativeHeaders.CE_SOURCE, 
String.valueOf(cloudEvent.getSource()))
+                        
.setBody(KnativeMessageFactory.createReader(cloudEvent))
+                        .execute();
+
+                Response response = execute.get(10, TimeUnit.SECONDS);
+                if (response.getStatusCode() != 
HttpConstants.ResponseStatusCodes.OK_200) {
+                    log.error("[KnativeSinkConnector] sendResult fail : {}", 
response.getResponseBody());;
+                }
+            } catch (InterruptedException e) {
+                Thread currentThread = Thread.currentThread();
+                log.warn("[KnativeSinkConnector] Interrupting thread {} due to 
exception {}", currentThread.getName(), e.getMessage());
+                currentThread.interrupt();
+            } catch (Exception e) {
+                log.error("[KnativeSinkConnector] sendResult has error : ", e);
+            }
+        }
+    }
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/config/KnativeSourceConfig.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/config/KnativeSourceConfig.java
new file mode 100644
index 000000000..8ef36a8d7
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/config/KnativeSourceConfig.java
@@ -0,0 +1,31 @@
+/*
+ * 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.connector.knative.source.config;
+
+import org.apache.eventmesh.openconnect.api.config.SourceConfig;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class KnativeSourceConfig extends SourceConfig {
+
+    public SourceConnectorConfig connectorConfig;
+
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/config/SourceConnectorConfig.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/config/SourceConnectorConfig.java
new file mode 100644
index 000000000..8d21c86b7
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/config/SourceConnectorConfig.java
@@ -0,0 +1,31 @@
+/*
+ * 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.connector.knative.source.config;
+
+import lombok.Data;
+
+@Data
+public class SourceConnectorConfig {
+
+    private String connectorName;
+
+    public String emurl;
+
+    public String serviceAddr;
+
+}
\ No newline at end of file
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/connector/KnativeSourceConnector.java
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/connector/KnativeSourceConnector.java
new file mode 100644
index 000000000..239c39a80
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/connector/KnativeSourceConnector.java
@@ -0,0 +1,79 @@
+/*
+ * 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.connector.knative.source.connector;
+
+import 
org.apache.eventmesh.connector.knative.source.config.KnativeSourceConfig;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class KnativeSourceConnector implements Source {
+
+    private KnativeSourceConfig sourceConfig;
+
+    private static final AtomicBoolean started = new AtomicBoolean(false);
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return KnativeSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) throws Exception {
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) throws Exception {
+        SourceConnectorContext sourceConnectorContext = 
(SourceConnectorContext) connectorContext;
+        this.sourceConfig = (KnativeSourceConfig) 
sourceConnectorContext.getSourceConfig();
+    }
+
+    @Override
+    public void start() throws Exception {
+        started.compareAndSet(false, true);
+    }
+
+    @Override
+    public void commit(ConnectRecord record) {
+    }
+
+    @Override
+    public String name() {
+        return this.sourceConfig.getConnectorConfig().getConnectorName();
+    }
+
+    @Override
+    public void stop() {
+        started.compareAndSet(true, false);
+    }
+
+    @Override
+    public List<ConnectRecord> poll() {
+        // todo: create a sink service and expose a public endpoint to Knative 
broker
+        // https://knative.dev/docs/eventing/sinks/
+        return null;
+    }
+}
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/server-config.yml
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/server-config.yml
new file mode 100644
index 000000000..5f66dd0f6
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/server-config.yml
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+sourceEnable: true
+sinkEnable: true
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/sink-config.yml
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/sink-config.yml
new file mode 100644
index 000000000..6340b667e
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/sink-config.yml
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+pubSubConfig:
+    meshAddress: 127.0.0.1:10000
+    subject: TopicTest
+    idc: FT
+    env: PRD
+    group: knativeSink
+    appId: 5031
+    userName: knativeSinkUser
+    passWord: knativePassWord
+connectorConfig:
+    connectorName: knativeSink
+    emurl: 127.0.0.1
+    serviceAddr: cloudevents-player.default.127.0.0.1.sslip.io
+
diff --git 
a/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/source-config.yml
 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/source-config.yml
new file mode 100644
index 000000000..dffc9cd02
--- /dev/null
+++ 
b/eventmesh-connectors/eventmesh-connector-knative/src/main/resources/source-config.yml
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+pubSubConfig:
+    meshAddress: 127.0.0.1:10000
+    subject: TopicTest
+    idc: FT
+    env: PRD
+    group: knativeSource
+    appId: 5032
+    userName: knativeSourceUser
+    passWord: knativePassWord
+connectorConfig:
+    connectorName: knativeSource
+    emurl: 127.0.0.1
+    serviceAddr: cloudevents-player.default.127.0.0.1.sslip.io
+offsetStorageConfig:
+    offsetStorageType: nacos
+    offsetStorageAddr: 127.0.0.1:8848
+    extensions: {
+                    #same with connectorName
+                    dataId: knativeSource,
+                    #same with group
+                    group: knativeSource
+    }
diff --git a/settings.gradle b/settings.gradle
index acb9ef15b..a1aad7463 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -28,17 +28,18 @@ include 'eventmesh-openconnect:eventmesh-openconnect-java'
 include 
'eventmesh-openconnect:eventmesh-openconnect-offsetmgmt-plugin:eventmesh-openconnect-offsetmgmt-api'
 include 
'eventmesh-openconnect:eventmesh-openconnect-offsetmgmt-plugin:eventmesh-openconnect-offsetmgmt-nacos'
 
+include 'eventmesh-connectors:eventmesh-connector-openfunction'
 include 'eventmesh-connectors:eventmesh-connector-rocketmq'
 include 'eventmesh-connectors:eventmesh-connector-rabbitmq'
 include 'eventmesh-connectors:eventmesh-connector-redis'
 include 'eventmesh-connectors:eventmesh-connector-mongodb'
-include 'eventmesh-connectors:eventmesh-connector-openfunction'
 include 'eventmesh-connectors:eventmesh-connector-pulsar'
 include 'eventmesh-connectors:eventmesh-connector-kafka'
 include 'eventmesh-connectors:eventmesh-connector-s3'
 include 'eventmesh-connectors:eventmesh-connector-pravega'
-
+include 'eventmesh-connectors:eventmesh-connector-knative'
 include 'eventmesh-connectors:eventmesh-connector-jdbc'
+
 include 'eventmesh-storage-plugin:eventmesh-storage-api'
 include 'eventmesh-storage-plugin:eventmesh-storage-standalone'
 include 'eventmesh-storage-plugin:eventmesh-storage-kafka'


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

Reply via email to