From 45907c27d59a37d23b5c056eff33a7d8b93b0f7a Mon Sep 17 00:00:00 2001 From: Nikolay Perfilov Date: Thu, 19 Oct 2023 14:45:54 +0300 Subject: [PATCH] Fix StartPartitionSessionSettings.Builder methods return value, add comments --- .../StartPartitionSessionSettings.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/topic/src/main/java/tech/ydb/topic/settings/StartPartitionSessionSettings.java b/topic/src/main/java/tech/ydb/topic/settings/StartPartitionSessionSettings.java index 067197830..b61b40ccb 100644 --- a/topic/src/main/java/tech/ydb/topic/settings/StartPartitionSessionSettings.java +++ b/topic/src/main/java/tech/ydb/topic/settings/StartPartitionSessionSettings.java @@ -28,12 +28,34 @@ public static class Builder { private Long readOffset; private Long commitOffset; - public void setReadOffset(Long readOffset) { + /** + * Reads in this partition session will start from offset no less than readOffset. + * If readOffset is set, server will check if that readOffset is not less than the actual committed offset. + * If the check fails then server will send an error message (status != SUCCESS) and close the stream. + * If readOffset is not set or is null (which is default), no check will be made. + * + * InitRequest.max_lag and InitRequest.read_from could lead to skip of more messages. + * Server will return data starting from offset that is maximum of actual committed offset, read_offset (if set) + * and offsets calculated from InitRequest.max_lag and InitRequest.read_from. + * + * @param readOffset Offset to read from. Default: null + * @return Builder + */ + public Builder setReadOffset(Long readOffset) { this.readOffset = readOffset; + return this; } - public void setCommitOffset(Long commitOffset) { + /** + * Make server know that all messages with offsets less than commitOffset were fully processed by client. + * Server will commit this position if it is not already done. + * + * @param commitOffset Commit offset, following the offset of last processed (committed) message. Default: null + * @return Builder + */ + public Builder setCommitOffset(Long commitOffset) { this.commitOffset = commitOffset; + return this; } public StartPartitionSessionSettings build() {