AlexAxeman commented on code in PR #18: URL: https://github.com/apache/flink-connector-kafka/pull/18#discussion_r1163098741
########## flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/sink/HeaderProducer.java: ########## @@ -0,0 +1,36 @@ +/* + * 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.kafka.sink; + +import org.apache.flink.annotation.PublicEvolving; + +import org.apache.kafka.common.header.Header; +import org.apache.kafka.common.header.Headers; +import org.apache.kafka.common.header.internals.RecordHeaders; + +import java.io.Serializable; +import java.util.ArrayList; + +/** Creates an {@link Iterable} of {@link Header}s from the input element. */ +@PublicEvolving +public interface HeaderProducer<IN> extends Serializable { + default Headers produceHeaders(IN input) { + return new RecordHeaders(new ArrayList<>()); Review Comment: Hm... Personally I don't really like that. The big thing about Optionals is to force the handling of possible `null` values. You don't need that protecting while returning collections, as you can always return an empty one, which is what I did. I'd much rather go for an empty (immutable) collection. Initially, I returned a `Iterable<Header>` and changed that to kafka API Headers upon request. I'm not really leaning to either side, so happy to change that back @RamanVerma, wdyt? -- 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]
