pandaapo commented on code in PR #4599:
URL: https://github.com/apache/eventmesh/pull/4599#discussion_r1413598725


##########
eventmesh-connectors/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/ImServiceHandler.java:
##########
@@ -0,0 +1,267 @@
+/*
+ * 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.lark.sink;
+
+import static 
org.apache.eventmesh.connector.lark.sink.connector.LarkSinkConnector.getTenantAccessToken;
+
+import org.apache.eventmesh.connector.lark.ConnectRecordExtensionKeys;
+import org.apache.eventmesh.connector.lark.config.LarkMessageTemplateType;
+import org.apache.eventmesh.connector.lark.sink.config.SinkConnectorConfig;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+
+import org.apache.commons.text.StringEscapeUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+import com.github.rholder.retry.Attempt;
+import com.github.rholder.retry.RetryException;
+import com.github.rholder.retry.RetryListener;
+import com.github.rholder.retry.Retryer;
+import com.github.rholder.retry.RetryerBuilder;
+import com.github.rholder.retry.StopStrategies;
+import com.github.rholder.retry.WaitStrategies;
+import com.lark.oapi.Client;
+import com.lark.oapi.card.enums.MessageCardHeaderTemplateEnum;
+import com.lark.oapi.card.model.MessageCard;
+import com.lark.oapi.card.model.MessageCardConfig;
+import com.lark.oapi.card.model.MessageCardElement;
+import com.lark.oapi.card.model.MessageCardHeader;
+import com.lark.oapi.card.model.MessageCardMarkdown;
+import com.lark.oapi.card.model.MessageCardPlainText;
+import com.lark.oapi.core.httpclient.OkHttpTransport;
+import com.lark.oapi.core.request.RequestOptions;
+import com.lark.oapi.core.utils.Lists;
+import com.lark.oapi.okhttp.OkHttpClient;
+import com.lark.oapi.service.im.v1.ImService;
+import com.lark.oapi.service.im.v1.enums.MsgTypeEnum;
+import com.lark.oapi.service.im.v1.model.CreateMessageReq;
+import com.lark.oapi.service.im.v1.model.CreateMessageReqBody;
+import com.lark.oapi.service.im.v1.model.CreateMessageResp;
+import com.lark.oapi.service.im.v1.model.ext.MessageText;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ImServiceHandler {
+
+    private static final ConcurrentHashMap<ConnectRecord, CreateMessageReq> 
UN_ACK_REQ = new ConcurrentHashMap<>();

Review Comment:
   I think there is still a need for retransmission when the response fails.
   
   Based on your idea, I think it's possible to add a configuration for 
asynchronous retry. When synchronizing, continue to use retrier and remove UN_ 
ACK_ REQ set. When asynchronous, use Scheduling ExecutorService to implement 
asynchronous requests. If you agree, it is also possible to simplify the 
process first and further improve it in the new PR.
   
   我觉得响应失败时的重传还是有需要的。
   
根据您的想法,我觉得可以增加是否异步重试的配置。同步时,继续使用retryer,移除UN_ACK_REQ集合。异步时,使用ScheduledExecutorService实现异步请求。如果您赞同的话,先简化处理,以后在新的PR进一步完善,也是可以的。



##########
eventmesh-connectors/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/ImServiceHandler.java:
##########
@@ -0,0 +1,267 @@
+/*
+ * 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.lark.sink;
+
+import static 
org.apache.eventmesh.connector.lark.sink.connector.LarkSinkConnector.getTenantAccessToken;
+
+import org.apache.eventmesh.connector.lark.ConnectRecordExtensionKeys;
+import org.apache.eventmesh.connector.lark.config.LarkMessageTemplateType;
+import org.apache.eventmesh.connector.lark.sink.config.SinkConnectorConfig;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+
+import org.apache.commons.text.StringEscapeUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+import com.github.rholder.retry.Attempt;
+import com.github.rholder.retry.RetryException;
+import com.github.rholder.retry.RetryListener;
+import com.github.rholder.retry.Retryer;
+import com.github.rholder.retry.RetryerBuilder;
+import com.github.rholder.retry.StopStrategies;
+import com.github.rholder.retry.WaitStrategies;
+import com.lark.oapi.Client;
+import com.lark.oapi.card.enums.MessageCardHeaderTemplateEnum;
+import com.lark.oapi.card.model.MessageCard;
+import com.lark.oapi.card.model.MessageCardConfig;
+import com.lark.oapi.card.model.MessageCardElement;
+import com.lark.oapi.card.model.MessageCardHeader;
+import com.lark.oapi.card.model.MessageCardMarkdown;
+import com.lark.oapi.card.model.MessageCardPlainText;
+import com.lark.oapi.core.httpclient.OkHttpTransport;
+import com.lark.oapi.core.request.RequestOptions;
+import com.lark.oapi.core.utils.Lists;
+import com.lark.oapi.okhttp.OkHttpClient;
+import com.lark.oapi.service.im.v1.ImService;
+import com.lark.oapi.service.im.v1.enums.MsgTypeEnum;
+import com.lark.oapi.service.im.v1.model.CreateMessageReq;
+import com.lark.oapi.service.im.v1.model.CreateMessageReqBody;
+import com.lark.oapi.service.im.v1.model.CreateMessageResp;
+import com.lark.oapi.service.im.v1.model.ext.MessageText;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ImServiceHandler {
+
+    private static final ConcurrentHashMap<ConnectRecord, CreateMessageReq> 
UN_ACK_REQ = new ConcurrentHashMap<>();

Review Comment:
   I think there is still a need for retransmission when the response fails.
   
   Based on your idea, I think it's possible to add a configuration for 
asynchronous retry. When synchronizing, continue to use retrier and remove UN_ 
ACK_ REQ set. When asynchronous, use Scheduling ExecutorService to implement 
asynchronous requests. If you agree, it is also possible to simplify the 
process first and further improve it in the new PR.
   
   我觉得响应失败时的重传还是有需要的。
   
根据您的想法,我觉得可以增加是否异步重试的配置。同步时,继续使用retryer,移除UN_ACK_REQ集合。异步时,使用ScheduledExecutorService实现异步请求。如果您赞同的话,先简化处理,以后在新的PR进一步完善,也是可以的。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to