com.spredfast.kafka.connect.s3.S3RecordsWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kafka-connect-s3 Show documentation
Show all versions of kafka-connect-s3 Show documentation
S3 Source and Sink Connectors for Kafka Connect
package com.spredfast.kafka.connect.s3;
import java.util.function.Function;
import java.util.stream.Stream;
import org.apache.kafka.clients.producer.ProducerRecord;
/**
*
*/
public interface S3RecordsWriter {
/**
* Opportunity to write any header bytes desired.
*/
default byte[] init(String topic, int partition, long startOffset) {
return new byte[0];
}
/**
* Called multiple times to encode a set of records. Should return one byte array per record.
*/
Stream writeBatch(Stream> records);
/**
* Hook for writing any trailer bytes to the S3 file.
*/
default byte[] finish(String topic, int partition) {
return new byte[0];
}
static S3RecordsWriter forRecordWriter(Function, byte[]> writeRecord) {
return records -> records.map(writeRecord);
}
}