Skip to content

Commit 87e6bdf

Browse files
committed
Python SDK topic reader without consumer docs
1 parent f5719d8 commit 87e6bdf

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

ydb/docs/en/core/reference/ydb-sdk/topic.md

+20
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,26 @@ Reading progress is usually saved on a server for each Consumer. However, such p
19281928
}
19291929
```
19301930

1931+
- Python
1932+
1933+
To read without a `Consumer`, create a reader using the `no_consumer_reader` method:
1934+
1935+
```python
1936+
def callee(partition_id: int) -> int:
1937+
return 0
1938+
1939+
reader = driver.topic_client.no_consumer_reader(
1940+
topic="topic-path",
1941+
partition_ids=[0,1,2],
1942+
get_start_offset_lambda=callee,
1943+
)
1944+
```
1945+
1946+
This method takes three required arguments:
1947+
* `topic` - the path to the topic;
1948+
* `partition_ids` - array of partition IDs to be read from;
1949+
* `get_start_offset_lambda` - is a function that will calculate the starting offset when the reader starts, as well as when it reconnects. It can be asynchronous.
1950+
19311951
{% endlist %}
19321952

19331953
### Reading in a transaction {#read-tx}

ydb/docs/ru/core/reference/ydb-sdk/topic.md

+21
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,27 @@
19311931
}
19321932
```
19331933
1934+
- Python
1935+
1936+
Для чтения без `Consumer`а следует создать читателя с помощью метода `no_consumer_reader`:
1937+
1938+
```python
1939+
def callee(partition_id: int) -> int:
1940+
return 0
1941+
1942+
reader = driver.topic_client.no_consumer_reader(
1943+
topic="topic-path",
1944+
partition_ids=[0,1,2],
1945+
get_start_offset_lambda=callee,
1946+
)
1947+
```
1948+
1949+
Данный метод принимает три обязательных аргумента:
1950+
* `topic` - путь до топика;
1951+
* `partition_ids` - массив id партиций, из которых будет производиться чтение;
1952+
* `get_start_offset_lambda` - функция, благодаря которой будет высчитываться стартовый offset при старте читателя, а так же при его переподключениях. Может быть асинхронной.
1953+
1954+
19341955
{% endlist %}
19351956
19361957
### Чтение в транзакции {#read-tx}

0 commit comments

Comments
 (0)