yhs0092 commented on code in PR #4875:
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/4875#discussion_r2276839863


##########
swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/sse/SseEventResponseEntity.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.servicecomb.swagger.invocation.sse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import jakarta.validation.constraints.NotNull;
+
+public class SseEventResponseEntity<T> {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(SseEventResponseEntity.class);
+
+  /**
+   * event id
+   */
+  private Integer id;
+
+  /**
+   * event type
+   */
+  private String event;
+
+  /**
+   * reconnection time
+   */
+  private Long retry;
+
+  /**
+   * business data
+   */
+  @NotNull
+  private T data;
+
+  public SseEventResponseEntity<T> id(int id) {
+    if (this.id != null) {
+      LOGGER.warn("origin id: [{}] is exists, overridden by the current value: 
[{}]", this.id, id);
+    }
+    this.id = id;
+    return this;
+  }
+
+  public SseEventResponseEntity<T> event(String event) {
+    if (!StringUtils.isEmpty(this.event)) {
+      LOGGER.warn("origin event: [{}] is exists, overridden by the current 
value: [{}]", this.event, event);
+    }
+    this.event = event;
+    return this;
+  }
+
+  public SseEventResponseEntity<T> retry(long retry) {
+    if (this.retry != null) {
+      LOGGER.warn("origin retry: [{}] is exists, overridden by the current 
value: [{}]", this.retry, retry);
+    }
+    this.retry = retry;
+    return this;
+  }
+
+  public SseEventResponseEntity<T> data(Object data) {
+    if (this.data != null) {
+      LOGGER.warn("origin data: [{}] is exists, overridden by the current 
value: [{}]", this.data, data);
+    }
+    this.data = (T) data;

Review Comment:
   同一条消息里, 可以有多行data, 所以这里还不能直接打告警日志再覆盖.
   
   还是参考 https://datatracker.ietf.org/doc/html/rfc8895
   
   > If a message has more than one "data" line, the value of the data field is 
the concatenation of the values on those lines. There can be only one "event" 
and "id" line per message. The "data" field is required; the others are 
optional.
   
   下图是RFC文档给出来的样例(注意红框部分):
   
   <img width="672" height="546" alt="image" 
src="https://github.com/user-attachments/assets/204ba950-23d0-4e10-b011-92964170675e";
 />
   



-- 
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]

Reply via email to