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


##########
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriter.java:
##########
@@ -344,69 +352,69 @@ public void write(InputT element, Context context) throws 
IOException, Interrupt
      * </ul>
      */
     private void nonBlockingFlush() throws InterruptedException {
-        while (!isInFlightRequestOrMessageLimitExceeded()
+        while (!rateLimitingStrategy.shouldBlock(createRequestInfo())
                 && (bufferedRequestEntries.size() >= getNextBatchSizeLimit()
                         || bufferedRequestEntriesTotalSizeInBytes >= 
maxBatchSizeInBytes)) {
             flush();
         }
     }
 
-    /**
-     * Determines if the sink should block and complete existing in flight 
requests before it may
-     * prudently create any new ones. This is exactly determined by if the 
number of requests
-     * currently in flight exceeds the maximum supported by the sink OR if the 
number of in flight
-     * messages exceeds the maximum determined to be appropriate by the rate 
limiting strategy.
-     */
-    private boolean isInFlightRequestOrMessageLimitExceeded() {
-        return inFlightRequestsCount >= maxInFlightRequests
-                || inFlightMessages >= rateLimitingStrategy.getRateLimit();
+    private RequestInfo createRequestInfo() {
+        int batchSize = getNextBatchSize();
+        Instant requestStartTime = Instant.now();
+        return RequestInfo.builder()
+                .setBatchSize(batchSize)
+                .setRequestStartTime(requestStartTime)
+                .build();

Review Comment:
   Happy to remove `requestStartTime`. It is not used by the current 
implementation of `RateLimitingStrategy` at the moment.



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