Skip to content

Commit

Permalink
Merge branch 'master' into apache#4522-feishu-connector
Browse files Browse the repository at this point in the history
# Conflicts:
#	eventmesh-examples/src/main/resources/application.properties
  • Loading branch information
hhuang1231 committed Dec 8, 2023
2 parents 782c521 + ee9ee4c commit fadb477
Show file tree
Hide file tree
Showing 102 changed files with 17,588 additions and 133 deletions.
2 changes: 2 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ header:
copyright-owner: Apache Software Foundation

paths-ignore:
- 'eventmesh-operator/config/crd/bases'
- 'eventmesh-operator/config/rbac'
- '.github/PULL_REQUEST_TEMPLATE'
- '.gitmodules'
- '**/.gitkeep'
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ subprojects {
dependency "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.0"
dependency "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.0"

dependency "com.squareup.okhttp3:okhttp:3.14.9"

dependency "org.asynchttpclient:async-http-client:2.12.0"
dependency "org.apache.httpcomponents:httpclient:4.5.13"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ public class ProtocolKey {

public static final String CLIENT_TYPE = "clienttype";

public static final String GRPC_RESPONSE_CODE = "status_code";
public static final String GRPC_RESPONSE_MESSAGE = "response_message";
public static final String GRPC_RESPONSE_CODE = "statuscode";
public static final String GRPC_RESPONSE_MESSAGE = "responsemessage";
public static final String GRPC_RESPONSE_TIME = "time";

public static final String SUB_MESSAGE_TYPE = "submessagetype";

/**
* CloudEvents spec
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
@NoArgsConstructor
public class SubscriptionReply {

public static final String TYPE = "subscription_reply";

private String producerGroup;

private String topic;
Expand Down
2 changes: 2 additions & 0 deletions eventmesh-connectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ Add a new connector by implementing the source/sink interface using :
| [Spring](eventmesh-connector-spring) | Sink ||
| WeCom | Source ||
| [WeCom](eventmesh-connector-wecom) | Sink ||
| WeChat | Source ||
| [WeChat](eventmesh-connector-wechat) | Sink ||
| More connectors will be added... | Source/Sink | N/A |
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
public interface ConnectRecordExtensionKeys {

String DINGTALK_TEMPLATE_TYPE_KEY = "dingtalktemplatetype";
String DINGTALK_TEMPLATE_TYPE = "dingtalktemplatetype";

String DINGTALK_MARKDOWN_MESSAGE_TITLE = "dingtalkmarkdownmessagetitle";
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,30 @@

public enum DingDingMessageTemplateType {

PLAIN_TEXT("sampleText"),
MARKDOWN("sampleMarkdown");
PLAIN_TEXT("text", "sampleText"),
MARKDOWN("markdown", "sampleMarkdown");

private final String templateType;

private final String templateKey;

DingDingMessageTemplateType(String templateKey) {
DingDingMessageTemplateType(String templateType, String templateKey) {
this.templateType = templateType;
this.templateKey = templateKey;
}

public String getTemplateType() {
return templateType;
}

public String getTemplateKey() {
return templateKey;
}

public static DingDingMessageTemplateType of(String templateKey) {
public static DingDingMessageTemplateType of(String templateType) {
return Arrays.stream(values())
.filter(v -> v.getTemplateKey().equals(templateKey))
.filter(v -> v.getTemplateType().equals(templateType))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("TemplateKey: " + templateKey + " not found."));
.orElseThrow(() -> new IllegalArgumentException("TemplateType: " + templateType + " not found."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public void put(List<ConnectRecord> sinkRecords) {
new OrgGroupSendHeaders();
orgGroupSendHeaders.xAcsDingtalkAccessToken = accessToken;

String templateTypeKey = record.getExtension(ConnectRecordExtensionKeys.DINGTALK_TEMPLATE_TYPE_KEY);
String templateTypeKey = record.getExtension(ConnectRecordExtensionKeys.DINGTALK_TEMPLATE_TYPE);
if (null == templateTypeKey || "null".equals(templateTypeKey)) {
templateTypeKey = DingDingMessageTemplateType.PLAIN_TEXT.getTemplateKey();
templateTypeKey = DingDingMessageTemplateType.PLAIN_TEXT.getTemplateType();
}
DingDingMessageTemplateType templateType = DingDingMessageTemplateType.of(templateTypeKey);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public void testSendMessageToDingDing() throws Exception {
RecordOffset offset = new RecordOffset();
ConnectRecord connectRecord = new ConnectRecord(partition, offset,
System.currentTimeMillis(), "Hello, EventMesh!".getBytes(StandardCharsets.UTF_8));
connectRecord.addExtension(ConnectRecordExtensionKeys.DINGTALK_TEMPLATE_TYPE_KEY,
DingDingMessageTemplateType.PLAIN_TEXT.getTemplateKey());
connectRecord.addExtension(ConnectRecordExtensionKeys.DINGTALK_TEMPLATE_TYPE,
DingDingMessageTemplateType.PLAIN_TEXT.getTemplateType());
records.add(connectRecord);
}
connector.put(records);
Expand Down
42 changes: 42 additions & 0 deletions eventmesh-connectors/eventmesh-connector-wechat/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.alibaba:fastjson'
implementation 'com.google.guava:guava'
implementation 'com.squareup.okhttp3:okhttp'

implementation "io.netty:netty-all"


compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

testImplementation "org.mockito:mockito-core"
testImplementation "org.mockito:mockito-junit-jupiter"
testImplementation "org.mockito:mockito-inline"
}
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.wechat.config;

import org.apache.eventmesh.openconnect.api.config.Config;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class WeChatConnectServerConfig extends Config {

private boolean sinkEnable;
}
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.wechat.server;

import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.connector.wechat.config.WeChatConnectServerConfig;
import org.apache.eventmesh.connector.wechat.sink.connector.WeChatSinkConnector;
import org.apache.eventmesh.openconnect.Application;
import org.apache.eventmesh.openconnect.util.ConfigUtil;

public class WeChatConnectServer {

public static void main(String[] args) throws Exception {

WeChatConnectServerConfig weChatConnectServerConfig = ConfigUtil.parse(WeChatConnectServerConfig.class,
Constants.CONNECT_SERVER_CONFIG_FILE_NAME);

if (weChatConnectServerConfig.isSinkEnable()) {
Application application = new Application();
application.run(WeChatSinkConnector.class);
}
}
}
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.wechat.sink.config;

import lombok.Data;

@Data
public class SinkConnectorConfig {

private String connectorName;

private String appId;

private String appSecret;
}
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.wechat.sink.config;

import org.apache.eventmesh.openconnect.api.config.SinkConfig;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class WeChatSinkConfig extends SinkConfig {

private SinkConnectorConfig sinkConnectorConfig;
}
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.wechat.sink.connector;

import lombok.Data;

@Data
public class TemplateMessageResponse {

private int errcode;

private String errmsg;

private String msgid;
}
Loading

0 comments on commit fadb477

Please sign in to comment.