forked from apache/eventmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE apache#4411] Add DingDing sink connnector. (apache#4557)
* Add dingding sink connector. * fix: Remove unused config. * fix: Remove unused config. * fix: review * Add example config. * fix: review * fix: continue when record data is null.
- Loading branch information
1 parent
709b211
commit fc900e5
Showing
14 changed files
with
647 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
eventmesh-connectors/eventmesh-connector-dingding/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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' | ||
testImplementation.exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' | ||
} | ||
|
||
dependencies { | ||
implementation project(":eventmesh-common") | ||
implementation project(":eventmesh-sdks:eventmesh-sdk-java") | ||
implementation project(":eventmesh-openconnect:eventmesh-openconnect-java") | ||
implementation "com.aliyun:dingtalk:2.0.61" | ||
implementation 'com.google.guava:guava' | ||
|
||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
|
||
testImplementation "org.mockito:mockito-core" | ||
testImplementation "org.mockito:mockito-junit-jupiter" | ||
} |
28 changes: 28 additions & 0 deletions
28
.../org/apache/eventmesh/connector/dingding/common/constants/ConnectRecordExtensionKeys.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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.dingding.common.constants; | ||
|
||
/** | ||
* Constants of record extension key. | ||
*/ | ||
public interface ConnectRecordExtensionKeys { | ||
|
||
String DINGDING_TEMPLATE_TYPE_KEY = "dingDingTemplateTypeKey"; | ||
|
||
String DINGDING_MARKDOWN_MESSAGE_TITLE = "dingDingMarkdownMessageTitle"; | ||
} |
30 changes: 30 additions & 0 deletions
30
...main/java/org/apache/eventmesh/connector/dingding/config/DingDingConnectServerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.dingding.config; | ||
|
||
import org.apache.eventmesh.openconnect.api.config.Config; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class DingDingConnectServerConfig extends Config { | ||
|
||
private boolean sinkEnable; | ||
} |
43 changes: 43 additions & 0 deletions
43
...main/java/org/apache/eventmesh/connector/dingding/config/DingDingMessageTemplateType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.dingding.config; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum DingDingMessageTemplateType { | ||
|
||
PLAIN_TEXT("sampleText"), | ||
MARKDOWN("sampleMarkdown"); | ||
|
||
private final String templateKey; | ||
|
||
DingDingMessageTemplateType(String templateKey) { | ||
this.templateKey = templateKey; | ||
} | ||
|
||
public String getTemplateKey() { | ||
return templateKey; | ||
} | ||
|
||
public static DingDingMessageTemplateType of(String templateKey) { | ||
return Arrays.stream(values()) | ||
.filter(v -> v.getTemplateKey().equals(templateKey)) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException("TemplateKey: " + templateKey + " not found.")); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...g/src/main/java/org/apache/eventmesh/connector/dingding/server/DingDingConnectServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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.dingding.server; | ||
|
||
import org.apache.eventmesh.common.Constants; | ||
import org.apache.eventmesh.connector.dingding.config.DingDingConnectServerConfig; | ||
import org.apache.eventmesh.connector.dingding.sink.connector.DingDingSinkConnector; | ||
import org.apache.eventmesh.openconnect.Application; | ||
import org.apache.eventmesh.openconnect.util.ConfigUtil; | ||
|
||
public class DingDingConnectServer { | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
DingDingConnectServerConfig dingDingConnectServerConfig = ConfigUtil.parse(DingDingConnectServerConfig.class, | ||
Constants.CONNECT_SERVER_CONFIG_FILE_NAME); | ||
|
||
if (dingDingConnectServerConfig.isSinkEnable()) { | ||
Application application = new Application(); | ||
application.run(DingDingSinkConnector.class); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...src/main/java/org/apache/eventmesh/connector/dingding/sink/config/DingDingSinkConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.dingding.sink.config; | ||
|
||
import org.apache.eventmesh.openconnect.api.config.SinkConfig; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class DingDingSinkConfig extends SinkConfig { | ||
|
||
private SinkConnectorConfig sinkConnectorConfig; | ||
} |
36 changes: 36 additions & 0 deletions
36
...rc/main/java/org/apache/eventmesh/connector/dingding/sink/config/SinkConnectorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.dingding.sink.config; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class SinkConnectorConfig { | ||
|
||
private String connectorName; | ||
|
||
private String appKey; | ||
|
||
private String appSecret; | ||
|
||
private String openConversationId; | ||
|
||
private String robotCode; | ||
|
||
private String coolAppCode; | ||
} |
Oops, something went wrong.