|
14 | 14 | "TopicError",
|
15 | 15 | "TopicMeteringMode",
|
16 | 16 | "TopicReader",
|
| 17 | + "TopicNoConsumerReaderAsyncIO", |
17 | 18 | "TopicReaderAsyncIO",
|
18 | 19 | "TopicReaderBatch",
|
19 | 20 | "TopicReaderMessage",
|
|
36 | 37 | import datetime
|
37 | 38 | from dataclasses import dataclass
|
38 | 39 | import logging
|
39 |
| -from typing import List, Union, Mapping, Optional, Dict, Callable |
| 40 | +from typing import Awaitable, List, Union, Mapping, Optional, Dict, Callable |
40 | 41 |
|
41 | 42 | from . import aio, Credentials, _apis, issues
|
42 | 43 |
|
|
52 | 53 | PublicTopicSelector as TopicReaderSelector,
|
53 | 54 | )
|
54 | 55 |
|
55 |
| -from ._topic_reader.topic_reader_sync import TopicReaderSync as TopicReader |
| 56 | +from ._topic_reader.topic_reader_sync import ( |
| 57 | + TopicReaderSync as TopicReader, |
| 58 | + TopicNoConsumerReaderSync as TopicNoConsumerReader, |
| 59 | +) |
56 | 60 |
|
57 | 61 | from ._topic_reader.topic_reader_asyncio import (
|
58 | 62 | PublicAsyncIOReader as TopicReaderAsyncIO,
|
| 63 | + PublicAsyncIONoConsumerReader as TopicNoConsumerReaderAsyncIO, |
59 | 64 | PublicTopicReaderPartitionExpiredError as TopicReaderPartitionExpiredError,
|
60 | 65 | PublicTopicReaderUnexpectedCodecError as TopicReaderUnexpectedCodecError,
|
61 | 66 | )
|
@@ -261,6 +266,31 @@ def reader(
|
261 | 266 |
|
262 | 267 | return TopicReaderAsyncIO(self._driver, settings, _parent=self)
|
263 | 268 |
|
| 269 | + def no_consumer_reader( |
| 270 | + self, |
| 271 | + topic: Union[str, TopicReaderSelector, List[Union[str, TopicReaderSelector]]], |
| 272 | + partition_ids: List[int], |
| 273 | + get_start_offset_lambda: Union[Callable[[int], int], Callable[[int], Awaitable[int]]], |
| 274 | + buffer_size_bytes: int = 50 * 1024 * 1024, |
| 275 | + # decoders: map[codec_code] func(encoded_bytes)->decoded_bytes |
| 276 | + # the func will be called from multiply threads in parallel |
| 277 | + decoders: Union[Mapping[int, Callable[[bytes], bytes]], None] = None, |
| 278 | + # custom decoder executor for call builtin and custom decoders. If None - use shared executor pool. |
| 279 | + # if max_worker in the executor is 1 - then decoders will be called from the thread without parallel |
| 280 | + decoder_executor: Optional[concurrent.futures.Executor] = None, |
| 281 | + auto_partitioning_support: Optional[bool] = True, # Auto partitioning feature flag. Default - True. |
| 282 | + ) -> TopicNoConsumerReaderAsyncIO: |
| 283 | + if not decoder_executor: |
| 284 | + decoder_executor = self._executor |
| 285 | + |
| 286 | + args = locals().copy() |
| 287 | + del args["self"] |
| 288 | + args["consumer"] = None |
| 289 | + |
| 290 | + settings = TopicReaderSettings(**args) |
| 291 | + |
| 292 | + return TopicNoConsumerReaderAsyncIO(self._driver, settings, _parent=self) |
| 293 | + |
264 | 294 | def writer(
|
265 | 295 | self,
|
266 | 296 | topic,
|
@@ -505,6 +535,31 @@ def reader(
|
505 | 535 |
|
506 | 536 | return TopicReader(self._driver, settings, _parent=self)
|
507 | 537 |
|
| 538 | + def no_consumer_reader( |
| 539 | + self, |
| 540 | + topic: Union[str, TopicReaderSelector, List[Union[str, TopicReaderSelector]]], |
| 541 | + partition_ids: List[int], |
| 542 | + get_start_offset_lambda: Union[Callable[[int], int], Callable[[int], Awaitable[int]]], |
| 543 | + buffer_size_bytes: int = 50 * 1024 * 1024, |
| 544 | + # decoders: map[codec_code] func(encoded_bytes)->decoded_bytes |
| 545 | + # the func will be called from multiply threads in parallel |
| 546 | + decoders: Union[Mapping[int, Callable[[bytes], bytes]], None] = None, |
| 547 | + # custom decoder executor for call builtin and custom decoders. If None - use shared executor pool. |
| 548 | + # if max_worker in the executor is 1 - then decoders will be called from the thread without parallel |
| 549 | + decoder_executor: Optional[concurrent.futures.Executor] = None, |
| 550 | + auto_partitioning_support: Optional[bool] = True, # Auto partitioning feature flag. Default - True. |
| 551 | + ) -> TopicNoConsumerReader: |
| 552 | + if not decoder_executor: |
| 553 | + decoder_executor = self._executor |
| 554 | + |
| 555 | + args = locals().copy() |
| 556 | + del args["self"] |
| 557 | + args["consumer"] = None |
| 558 | + |
| 559 | + settings = TopicReaderSettings(**args) |
| 560 | + |
| 561 | + return TopicNoConsumerReader(self._driver, settings, _parent=self) |
| 562 | + |
508 | 563 | def writer(
|
509 | 564 | self,
|
510 | 565 | topic,
|
|
0 commit comments