CrynetLogistics commented on a change in pull request #17068: URL: https://github.com/apache/flink/pull/17068#discussion_r700951348
########## File path: flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriter.java ########## @@ -0,0 +1,235 @@ +/* + * 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; + +import org.apache.flink.api.common.operators.MailboxExecutor; +import org.apache.flink.api.connector.sink.Sink; +import org.apache.flink.api.connector.sink.SinkWriter; +import org.apache.flink.util.Preconditions; + +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Deque; +import java.util.List; +import java.util.NoSuchElementException; + +/** AsyncSinkWriter. */ +public abstract class AsyncSinkWriter<InputT, RequestEntryT extends Serializable> + implements SinkWriter<InputT, Void, Collection<RequestEntryT>> { + + private final MailboxExecutor mailboxExecutor; + private final Sink.ProcessingTimeService timeService; + + private final int maxBatchSize; + private final int maxInFlightRequests; + private final int maxBufferedRequests; + + public AsyncSinkWriter( + ElementConverter<InputT, RequestEntryT> elementConverter, + Sink.InitContext context, + int maxBatchSize, + int maxInFlightRequests, + int maxBufferedRequests) { + this.elementConverter = elementConverter; + this.mailboxExecutor = context.getMailboxExecutor(); + this.timeService = context.getProcessingTimeService(); + + Preconditions.checkArgument( Review comment: I agree. I guess another helpful check would be to ensure maxBufferedRequests * sizeof(RequestEntryT) is a reasonable size, but not too sure how to make that concrete assertion - i.e. what limit should we set? 🤔 -- 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]
