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


##########
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:
   Builder pattern uses most of its use for parameters that are obligatory. 
What's the point of giving flexibility to call 
   ```
   RequestInfo.builder().build();
   ```
   If the only thing it does, is throwing an exception that some parameters 
were not set?
   
   On top of that, for a trivial 2 parameters POJO, that doesn't have to be 
constructed in the `@Public`/`@PublicEvolving` API, builder is an overkill IMO. 
As I suggested elsewhere, you could make `@PublicEvolving` `RequestInfo` as an 
interface with only the getters, and just have `@Internal` `class 
RequestInfoImpl` without any builder. Construction would be simpler while 
public api would be smaller and more flexibly for 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: [email protected]

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

Reply via email to