Skip to content

Commit

Permalink
add notification about close reader (ydb-platform#13368)
Browse files Browse the repository at this point in the history
Co-authored-by: anton-bobkov <anton-bobkov@ydb.tech>
Co-authored-by: Ivan Blinkov <ivan@ydb.tech>
  • Loading branch information
3 people authored and azevaykin committed Feb 3, 2025
1 parent 1690a34 commit c16abab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ydb/docs/en/core/reference/ydb-sdk/topic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions ydb/docs/ru/core/reference/ydb-sdk/topic.md
Original file line number Diff line number Diff line change
Expand Up @@ -1410,15 +1410,21 @@
}
```

По умолчанию `Commit` — это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно с помощью вызова `Reader.Close()`.

- Python

`commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно.

```python
while True:
message = reader.receive_message()
process(message)
reader.commit(message)
```

`commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно.

- Java

Для подтверждения обработки сообщения достаточно вызвать у сообщения метод `commit`.
Expand Down Expand Up @@ -1481,6 +1487,8 @@
}
```

По умолчанию `Commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно.

- Python

```python
Expand All @@ -1490,6 +1498,8 @@
reader.commit(batch)
```

`commit` - это быстрый вызов: сохраняет данные во внутреннем буфере и сразу возвращает управление, а реальная отправка происходит позже. Поэтому, чтобы не терять последние коммиты перед выходом из программы, читателя нужно закрывать явно.

- Java (sync)

Неактуально, т.к. в синхронном читателе нет возможности читать сообщения пакетами.
Expand Down

0 comments on commit c16abab

Please sign in to comment.