hlteoh37 commented on code in PR #20245:
URL: https://github.com/apache/flink/pull/20245#discussion_r927824434


##########
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/strategy/RequestInfo.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.flink.connector.base.sink.writer.strategy;
+
+import org.apache.flink.annotation.PublicEvolving;
+
+import java.time.Instant;
+
+/** Dataclass to encapsulate information about starting requests. */
+@PublicEvolving
+public class RequestInfo {
+    private final int batchSize;
+    private final Instant requestStartTime;
+
+    private RequestInfo(int batchSize, Instant requestStartTime) {
+        this.batchSize = batchSize;
+        this.requestStartTime = requestStartTime;
+    }
+
+    @PublicEvolving
+    public static RequestInfoBuilder builder() {
+        return new RequestInfoBuilder();
+    }
+
+    public int getBatchSize() {
+        return batchSize;
+    }
+
+    public Instant getRequestStartTime() {
+        return requestStartTime;
+    }
+
+    /** Builder for {@link RequestInfo} dataclass. */
+    public static class RequestInfoBuilder {
+        private int batchSize;
+        private Instant requestStartTime;
+
+        public RequestInfoBuilder setBatchSize(final int batchSize) {
+            this.batchSize = batchSize;
+            return this;
+        }
+
+        public RequestInfoBuilder setRequestStartTime(final Instant 
requestStartTime) {
+            this.requestStartTime = requestStartTime;
+            return this;
+        }
+
+        public RequestInfo build() {
+            return new RequestInfo(batchSize, requestStartTime);
+        }
+    }

Review Comment:
   I think a fluent builder makes the code more readable, especially for a 
dataclass like this, which can be extended to have more information in the 
future.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to