tech.ydb.topic.read.impl.events.DataReceivedEventImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-sdk-topic Show documentation
Show all versions of ydb-sdk-topic Show documentation
Topic client implementation
The newest version!
package tech.ydb.topic.read.impl.events;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import tech.ydb.topic.description.OffsetsRange;
import tech.ydb.topic.read.Message;
import tech.ydb.topic.read.PartitionOffsets;
import tech.ydb.topic.read.PartitionSession;
import tech.ydb.topic.read.events.DataReceivedEvent;
import tech.ydb.topic.read.impl.CommitterImpl;
import tech.ydb.topic.read.impl.PartitionSessionImpl;
/**
* @author Nikolay Perfilov
*/
public class DataReceivedEventImpl implements DataReceivedEvent {
private final List messages;
private final PartitionSessionImpl partitionSession;
private final OffsetsRange offsetsToCommit;
private final CommitterImpl committer;
public DataReceivedEventImpl(PartitionSessionImpl partitionSession, List messages,
OffsetsRange offsetsToCommit) {
this.messages = messages;
this.partitionSession = partitionSession;
this.offsetsToCommit = offsetsToCommit;
this.committer = new CommitterImpl(partitionSession, messages.size(), offsetsToCommit);
}
@Override
public List getMessages() {
return messages;
}
@Override
public PartitionOffsets getPartitionOffsets() {
return new PartitionOffsets(partitionSession.getSessionInfo(), Collections.singletonList(offsetsToCommit));
}
@Override
public PartitionSession getPartitionSession() {
return partitionSession.getSessionInfo();
}
public PartitionSessionImpl getPartitionSessionImpl() {
return partitionSession;
}
@Override
public CompletableFuture commit() {
return committer.commitImpl(false);
}
public OffsetsRange getOffsetsToCommit() {
return offsetsToCommit;
}
}