You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ydb/docs/en/core/reference/ydb-sdk/topic.md
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1184,7 +1184,8 @@ All the metadata provided when writing a message is sent to a consumer with the
1184
1184
1185
1185
### Connecting to a topic for message reads {#start-reader}
1186
1186
1187
-
To be able to read messages from topic, a Consumer on this topic should exist.
1187
+
Reading messages from a topic can be done by specifying a Consumer associated with that topic, as well as without a Consumer. If a Consumer isnot specified, the client application must calculate the offset for reading messages on its own. A more detailed example of reading without a Consumer is discussed in the [relevant section](#no-consumer).
1188
+
1188
1189
A Consumer can be created on [creating](#create-topic) or [altering](#alter-topic) a topic.
1189
1190
Topic can have several Consumers andfor each of them server stores its own reading progress.
1190
1191
@@ -1222,7 +1223,7 @@ Topic can have several Consumers and for each of them server stores its own read
1222
1223
To establish a connection to the existing `my-topic` topic using the added `my-consumer` consumer, use the following code:
@@ -1928,6 +1929,32 @@ Reading progress is usually saved on a server for each Consumer. However, such p
1928
1929
}
1929
1930
```
1930
1931
1932
+
- Python
1933
+
1934
+
To read without a `Consumer`, create a reader using the `reader` method with specifying these arguments:
1935
+
*`topic`-`ydb.TopicReaderSelector`objectwith defined `path`and`partitions`list;
1936
+
*`consumer`- should be `None`;
1937
+
*`event_handler`- inheritor of `ydb.TopicReaderEvents.EventHandler` that implements the `on_partition_get_start_offset` function. This function is responsible for returning the initial offset for reading messages when the reader starts and during reconnections. The client application must specify this offset in the parameter `ydb.TopicReaderEvents.OnPartitionGetStartOffsetResponse.start_offset`. The function can also be implemented as asynchronous.
1938
+
1939
+
Example:
1940
+
1941
+
```python
1942
+
class CustomEventHandler(ydb.TopicReaderEvents.EventHandler):
Copy file name to clipboardExpand all lines: ydb/docs/ru/core/reference/ydb-sdk/topic.md
+30-3Lines changed: 30 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1182,7 +1182,8 @@
1182
1182
1183
1183
### Подключение к топику для чтения сообщений {#start-reader}
1184
1184
1185
-
Для чтения сообщений из топика необходимо наличие заранее созданного Consumer, связанного с этим топиком.
1185
+
Чтение сообщений из топика может выполнятся с указанием Consumer'а, связанного с этим топиком, а также без Consumer'а. Если Consumer не указан, то клиентское приложение должно самостоятельно рассчитывать offset для чтения сообщений. Более подробно пример чтения без Consumer'а рассмотрен в [соответствующей секции](#no-consumer).
1186
+
1186
1187
Создать Consumer можно при [создании](#create-topic) или [изменении](#alter-topic) топика.
1187
1188
У топика может быть несколько Consumer'ов и для каждого из них сервер хранит свой прогресс чтения.
1188
1189
@@ -1220,7 +1221,7 @@
1220
1221
Чтобы создать подключение к существующему топику `my-topic` через добавленного ранее читателя `my-consumer`, используйте следующий код:
Для чтения без Consumer'а следует создать читателя с помощью метода `reader` с указанием следующих аргументов:
1938
+
* `topic` - объект `ydb.TopicReaderSelector` с указанными `path` и списком `partitions`;
1939
+
* `consumer` - должен быть `None`;
1940
+
* `event_handler` - наследник `ydb.TopicReaderEvents.EventHandler`, который реализует функцию `on_partition_get_start_offset`. Эта функция отвечает за возвращение начального смещения (offset) для чтения сообщений при старте читателя, а также во время переподключений. Клиентское приложение должно указать это смещение в параметре `ydb.TopicReaderEvents.OnPartitionGetStartOffsetResponse.start_offset`. Также функция может быть реализована как асинхронная.
0 commit comments