From c16abab4145937079240a28a786b83ad276d8831 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Mon, 3 Feb 2025 08:47:26 +0300 Subject: [PATCH] add notification about close reader (#13368) Co-authored-by: anton-bobkov Co-authored-by: Ivan Blinkov --- ydb/docs/en/core/reference/ydb-sdk/topic.md | 8 ++++++++ ydb/docs/ru/core/reference/ydb-sdk/topic.md | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/ydb/docs/en/core/reference/ydb-sdk/topic.md b/ydb/docs/en/core/reference/ydb-sdk/topic.md index 1ca0018783a0..fd46638e7da9 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/topic.md +++ b/ydb/docs/en/core/reference/ydb-sdk/topic.md @@ -1412,6 +1412,8 @@ If a commit fails with an error, the application should log it and continue; it } ``` + The `Commit` call is fast by default, saving data into an internal buffer and returning control to the caller. The real message to the server is sent in the background. To prevent losing the last commits, call the `Reader.Close()` method before exiting the program. + - Python ```python @@ -1421,6 +1423,8 @@ If a commit fails with an error, the application should log it and continue; it reader.commit(message) ``` + The `commit` call is fast, saving data into an internal buffer and returning control back to the caller. The real message to the server is sent in the background. To prevent losing the last commits, you should call the `Reader.Close()` method before exiting the program. + - Java To commit a message just call `commit` method on it. @@ -1481,6 +1485,8 @@ If a commit fails with an error, the application should log it and continue; it } ``` + The `Commit` call is fast by default, saving data into an internal buffer and returning control back to the caller. The real message to the server is sent in the background. To prevent losing the last commits, you should call the `Reader.Close()` method before exiting the program. + - Python ```python @@ -1490,6 +1496,8 @@ If a commit fails with an error, the application should log it and continue; it reader.commit(batch) ``` + The `commit` call is fast, saving data into an internal buffer and returning control back to the caller. The real message to the server is sent in the background. To prevent losing the last commits, you should call the `Reader.Close()` method before exiting the program. + - Java (sync) Not relevant due to sync reader only reading messages one by one. diff --git a/ydb/docs/ru/core/reference/ydb-sdk/topic.md b/ydb/docs/ru/core/reference/ydb-sdk/topic.md index 9da57cf45ee5..70dd696263cc 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/topic.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/topic.md @@ -1410,8 +1410,12 @@ } ``` + По умолчанию `Commit` — это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно с помощью вызова `Reader.Close()`. + - Python + `commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно. + ```python while True: message = reader.receive_message() @@ -1419,6 +1423,8 @@ reader.commit(message) ``` + `commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно. + - Java Для подтверждения обработки сообщения достаточно вызвать у сообщения метод `commit`. @@ -1481,6 +1487,8 @@ } ``` + По умолчанию `Commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно. + - Python ```python @@ -1490,6 +1498,8 @@ reader.commit(batch) ``` + `commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно. + - Java (sync) Неактуально, т.к. в синхронном читателе нет возможности читать сообщения пакетами.