1
- import concurrent .futures
2
1
import enum
3
2
import datetime
4
3
from dataclasses import dataclass
5
4
from typing import (
6
5
Union ,
7
6
Optional ,
8
7
List ,
9
- Iterable ,
10
8
)
11
9
12
10
from ..table import RetrySettings
13
- from .datatypes import ICommittable , PublicBatch , PublicMessage
14
11
from .._topic_common .common import TokenGetterFuncType
15
12
from .._grpc .grpcwrapper .ydb_topic import StreamReadMessage , OffsetsRange
16
13
@@ -26,130 +23,6 @@ def __init__(self, path, *, partitions: Union[None, int, List[int]] = None):
26
23
self .partitions = partitions
27
24
28
25
29
- class Reader (object ):
30
- def async_sessions_stat (self ) -> concurrent .futures .Future :
31
- """
32
- Receive stat from the server, return feature.
33
- """
34
- raise NotImplementedError ()
35
-
36
- async def sessions_stat (self ) -> List ["SessionStat" ]:
37
- """
38
- Receive stat from the server
39
-
40
- use async_sessions_stat for set explicit wait timeout
41
- """
42
- raise NotImplementedError ()
43
-
44
- def messages (
45
- self , * , timeout : Union [float , None ] = None
46
- ) -> Iterable [PublicMessage ]:
47
- """
48
- todo?
49
-
50
- Block until receive new message
51
- It has no async_ version for prevent lost messages, use async_wait_message as signal for new batches available.
52
-
53
- if no new message in timeout seconds (default - infinite): stop iterations by raise StopIteration
54
- if timeout <= 0 - it will fast non block method, get messages from internal buffer only.
55
- """
56
- raise NotImplementedError ()
57
-
58
- def receive_message (self , * , timeout : Union [float , None ] = None ) -> PublicMessage :
59
- """
60
- Block until receive new message
61
- It has no async_ version for prevent lost messages, use async_wait_message as signal for new batches available.
62
-
63
- if no new message in timeout seconds (default - infinite): raise TimeoutError()
64
- if timeout <= 0 - it will fast non block method, get messages from internal buffer only.
65
- """
66
- raise NotImplementedError ()
67
-
68
- def async_wait_message (self ) -> concurrent .futures .Future :
69
- """
70
- Return future, which will completed when the reader has least one message in queue.
71
- If reader already has message - future will return completed.
72
-
73
- Possible situation when receive signal about message available, but no messages when try to receive a message.
74
- If message expired between send event and try to retrieve message (for example connection broken).
75
- """
76
- raise NotImplementedError ()
77
-
78
- def batches (
79
- self ,
80
- * ,
81
- max_messages : Union [int , None ] = None ,
82
- max_bytes : Union [int , None ] = None ,
83
- timeout : Union [float , None ] = None ,
84
- ) -> Iterable [PublicBatch ]:
85
- """
86
- Block until receive new batch.
87
- It has no async_ version for prevent lost messages, use async_wait_message as signal for new batches available.
88
-
89
- if no new message in timeout seconds (default - infinite): stop iterations by raise StopIteration
90
- if timeout <= 0 - it will fast non block method, get messages from internal buffer only.
91
- """
92
- raise NotImplementedError ()
93
-
94
- def receive_batch (
95
- self ,
96
- * ,
97
- max_messages : Union [int , None ] = None ,
98
- max_bytes : Union [int , None ],
99
- timeout : Union [float , None ] = None ,
100
- ) -> Union [PublicBatch , None ]:
101
- """
102
- Get one messages batch from reader
103
- It has no async_ version for prevent lost messages, use async_wait_message as signal for new batches available.
104
-
105
- if no new message in timeout seconds (default - infinite): raise TimeoutError()
106
- if timeout <= 0 - it will fast non block method, get messages from internal buffer only.
107
- """
108
- raise NotImplementedError ()
109
-
110
- def commit (self , mess : ICommittable ):
111
- """
112
- Put commit message to internal buffer.
113
-
114
- For the method no way check the commit result
115
- (for example if lost connection - commits will not re-send and committed messages will receive again)
116
- """
117
- raise NotImplementedError ()
118
-
119
- def commit_with_ack (
120
- self , mess : ICommittable
121
- ) -> Union ["CommitResult" , List ["CommitResult" ]]:
122
- """
123
- write commit message to a buffer and wait ack from the server.
124
-
125
- if receive in timeout seconds (default - infinite): raise TimeoutError()
126
- """
127
- raise NotImplementedError ()
128
-
129
- def async_commit_with_ack (
130
- self , mess : ICommittable
131
- ) -> Union ["CommitResult" , List ["CommitResult" ]]:
132
- """
133
- write commit message to a buffer and return Future for wait result.
134
- """
135
- raise NotImplementedError ()
136
-
137
- def async_flush (self ) -> concurrent .futures .Future :
138
- """
139
- force send all commit messages from internal buffers to server and return Future for wait server acks.
140
- """
141
- raise NotImplementedError ()
142
-
143
- def flush (self ):
144
- """
145
- force send all commit messages from internal buffers to server and wait acks for all of them.
146
- """
147
- raise NotImplementedError ()
148
-
149
- def close (self ):
150
- raise NotImplementedError ()
151
-
152
-
153
26
@dataclass
154
27
class PublicReaderSettings :
155
28
consumer : str
0 commit comments