-
Notifications
You must be signed in to change notification settings - Fork 312
Expand file tree
/
Copy pathapache_iggy.pyi
More file actions
538 lines (467 loc) · 18.6 KB
/
apache_iggy.pyi
File metadata and controls
538 lines (467 loc) · 18.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401
import asyncio
import builtins
import collections.abc
import datetime
import typing
class AutoCommit:
r"""
The auto-commit configuration for storing the offset on the server.
"""
class Disabled(AutoCommit):
r"""
The auto-commit is disabled and the offset must be stored manually by the consumer.
"""
__match_args__ = ((),)
def __new__(cls) -> AutoCommit.Disabled: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class Interval(AutoCommit):
r"""
The auto-commit is enabled and the offset is stored on the server after a certain interval.
"""
__match_args__ = ("_0",)
@property
def _0(self) -> datetime.timedelta: ...
def __new__(cls, _0: datetime.timedelta) -> AutoCommit.Interval: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class IntervalOrWhen(AutoCommit):
r"""
The auto-commit is enabled and the offset is stored on the server after a certain interval or depending on the mode when consuming the messages.
"""
__match_args__ = (
"_0",
"_1",
)
@property
def _0(self) -> datetime.timedelta: ...
@property
def _1(self) -> AutoCommitWhen: ...
def __new__(
cls, _0: datetime.timedelta, _1: AutoCommitWhen
) -> AutoCommit.IntervalOrWhen: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class IntervalOrAfter(AutoCommit):
r"""
The auto-commit is enabled and the offset is stored on the server after a certain interval or depending on the mode after consuming the messages.
"""
__match_args__ = (
"_0",
"_1",
)
@property
def _0(self) -> datetime.timedelta: ...
@property
def _1(self) -> AutoCommitAfter: ...
def __new__(
cls, _0: datetime.timedelta, _1: AutoCommitAfter
) -> AutoCommit.IntervalOrAfter: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class When(AutoCommit):
r"""
The auto-commit is enabled and the offset is stored on the server depending on the mode when consuming the messages.
"""
__match_args__ = ("_0",)
@property
def _0(self) -> AutoCommitWhen: ...
def __new__(cls, _0: AutoCommitWhen) -> AutoCommit.When: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class After(AutoCommit):
r"""
The auto-commit is enabled and the offset is stored on the server depending on the mode after consuming the messages.
"""
__match_args__ = ("_0",)
@property
def _0(self) -> AutoCommitAfter: ...
def __new__(cls, _0: AutoCommitAfter) -> AutoCommit.After: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
...
class AutoCommitAfter:
r"""
The auto-commit mode for storing the offset on the server **after** receiving the messages.
"""
class ConsumingAllMessages(AutoCommitAfter):
r"""
The offset is stored on the server after all the messages are consumed.
"""
__match_args__ = ((),)
def __new__(cls) -> AutoCommitAfter.ConsumingAllMessages: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class ConsumingEachMessage(AutoCommitAfter):
r"""
The offset is stored on the server after consuming each message.
"""
__match_args__ = ((),)
def __new__(cls) -> AutoCommitAfter.ConsumingEachMessage: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class ConsumingEveryNthMessage(AutoCommitAfter):
r"""
The offset is stored on the server after consuming every Nth message.
"""
__match_args__ = ("_0",)
@property
def _0(self) -> builtins.int: ...
def __new__(
cls, _0: builtins.int
) -> AutoCommitAfter.ConsumingEveryNthMessage: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
...
class AutoCommitWhen:
r"""
The auto-commit mode for storing the offset on the server.
"""
class PollingMessages(AutoCommitWhen):
r"""
The offset is stored on the server when the messages are received.
"""
__match_args__ = ((),)
def __new__(cls) -> AutoCommitWhen.PollingMessages: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class ConsumingAllMessages(AutoCommitWhen):
r"""
The offset is stored on the server when all the messages are consumed.
"""
__match_args__ = ((),)
def __new__(cls) -> AutoCommitWhen.ConsumingAllMessages: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class ConsumingEachMessage(AutoCommitWhen):
r"""
The offset is stored on the server when consuming each message.
"""
__match_args__ = ((),)
def __new__(cls) -> AutoCommitWhen.ConsumingEachMessage: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
class ConsumingEveryNthMessage(AutoCommitWhen):
r"""
The offset is stored on the server when consuming every Nth message.
"""
__match_args__ = ("_0",)
@property
def _0(self) -> builtins.int: ...
def __new__(
cls, _0: builtins.int
) -> AutoCommitWhen.ConsumingEveryNthMessage: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int) -> typing.Any: ...
...
class IggyClient:
r"""
A Python class representing the Iggy client.
It wraps the RustIggyClient and provides asynchronous functionality
through the contained runtime.
"""
def __new__(cls, conn: typing.Optional[builtins.str] = None) -> IggyClient:
r"""
Constructs a new IggyClient from a TCP server address.
This initializes a new runtime for asynchronous operations.
Future versions might utilize asyncio for more Pythonic async.
"""
@classmethod
def from_connection_string(cls, connection_string: builtins.str) -> IggyClient:
r"""
Constructs a new IggyClient from a connection string.
Returns an error if the connection string provided is invalid.
"""
def ping(self) -> collections.abc.Awaitable[None]:
r"""
Sends a ping request to the server to check connectivity.
Returns `Ok(())` if the server responds successfully, or a `PyRuntimeError`
if the connection fails.
"""
def login_user(
self, username: builtins.str, password: builtins.str
) -> collections.abc.Awaitable[None]:
r"""
Logs in the user with the given credentials.
Returns `Ok(())` on success, or a PyRuntimeError on failure.
"""
def connect(self) -> collections.abc.Awaitable[None]:
r"""
Connects the IggyClient to its service.
Returns Ok(()) on successful connection or a PyRuntimeError on failure.
"""
def create_stream(self, name: builtins.str) -> collections.abc.Awaitable[None]:
r"""
Creates a new stream with the provided name.
Returns Ok(()) on successful stream creation or a PyRuntimeError on failure.
"""
def get_stream(
self, stream_id: builtins.str | builtins.int
) -> collections.abc.Awaitable[typing.Optional[StreamDetails]]:
r"""
Gets stream by id.
Returns Option of stream details or a PyRuntimeError on failure.
"""
def update_stream(
self, stream_id: builtins.str | builtins.int, name: builtins.str
) -> collections.abc.Awaitable[None]:
r"""
Updates a stream's name.
Returns Ok(()) on successful stream update or a PyRuntimeError on failure.
"""
def delete_stream(
self, stream_id: builtins.str | builtins.int
) -> collections.abc.Awaitable[None]:
r"""
Deletes a stream by id.
Returns Ok(()) on successful stream deletion or a PyRuntimeError on failure.
"""
def create_topic(
self,
stream: builtins.str | builtins.int,
name: builtins.str,
partitions_count: builtins.int,
compression_algorithm: typing.Optional[builtins.str] = None,
replication_factor: typing.Optional[builtins.int] = None,
message_expiry: typing.Optional[datetime.timedelta] = None,
max_topic_size: typing.Optional[builtins.int] = None,
) -> collections.abc.Awaitable[None]:
r"""
Creates a new topic with the given parameters.
Returns Ok(()) on successful topic creation or a PyRuntimeError on failure.
"""
def get_topic(
self,
stream_id: builtins.str | builtins.int,
topic_id: builtins.str | builtins.int,
) -> collections.abc.Awaitable[typing.Optional[TopicDetails]]:
r"""
Gets topic by stream and id.
Returns Option of topic details or a PyRuntimeError on failure.
"""
def send_messages(
self,
stream: builtins.str | builtins.int,
topic: builtins.str | builtins.int,
partitioning: builtins.int,
messages: list[SendMessage],
) -> collections.abc.Awaitable[None]:
r"""
Sends a list of messages to the specified topic.
Returns Ok(()) on successful sending or a PyRuntimeError on failure.
"""
def poll_messages(
self,
stream: builtins.str | builtins.int,
topic: builtins.str | builtins.int,
partition_id: builtins.int,
polling_strategy: PollingStrategy,
count: builtins.int,
auto_commit: builtins.bool,
) -> collections.abc.Awaitable[list[ReceiveMessage]]:
r"""
Polls for messages from the specified topic and partition.
Returns a list of received messages or a PyRuntimeError on failure.
"""
def consumer_group(
self,
name: builtins.str,
stream: builtins.str,
topic: builtins.str,
partition_id: typing.Optional[builtins.int] = None,
polling_strategy: typing.Optional[PollingStrategy] = None,
batch_length: typing.Optional[builtins.int] = None,
auto_commit: typing.Optional[AutoCommit] = None,
create_consumer_group_if_not_exists: builtins.bool = True,
auto_join_consumer_group: builtins.bool = True,
poll_interval: typing.Optional[datetime.timedelta] = None,
polling_retry_interval: typing.Optional[datetime.timedelta] = None,
init_retries: typing.Optional[builtins.int] = None,
init_retry_interval: typing.Optional[datetime.timedelta] = None,
allow_replay: builtins.bool = False,
) -> collections.abc.Awaitable[IggyConsumer]:
r"""
Creates a new consumer group consumer.
Returns the consumer or a PyRuntimeError on failure.
"""
class IggyConsumer:
r"""
A Python class representing the Iggy consumer.
It wraps the RustIggyConsumer and provides asynchronous functionality
through the contained runtime.
"""
def get_last_consumed_offset(
self, partition_id: builtins.int
) -> typing.Optional[builtins.int]:
r"""
Get the last consumed offset or `None` if no offset has been consumed yet.
"""
def get_last_stored_offset(
self, partition_id: builtins.int
) -> typing.Optional[builtins.int]:
r"""
Get the last stored offset or `None` if no offset has been stored yet.
"""
def name(self) -> builtins.str:
r"""
Gets the name of the consumer group.
"""
def partition_id(self) -> builtins.int:
r"""
Gets the current partition id or `0` if no messages have been polled yet.
"""
def stream(self) -> builtins.str | builtins.int:
r"""
Gets the name of the stream this consumer group is configured for.
"""
def topic(self) -> builtins.str | builtins.int:
r"""
Gets the name of the topic this consumer group is configured for.
"""
def store_offset(
self, offset: builtins.int, partition_id: typing.Optional[builtins.int]
) -> collections.abc.Awaitable[None]:
r"""
Stores the provided offset for the provided partition id or if none is specified
uses the current partition id for the consumer group.
Returns `Ok(())` if the server responds successfully, or a `PyRuntimeError`
if the operation fails.
"""
def delete_offset(
self, partition_id: typing.Optional[builtins.int]
) -> collections.abc.Awaitable[None]:
r"""
Deletes the offset for the provided partition id or if none is specified
uses the current partition id for the consumer group.
Returns `Ok(())` if the server responds successfully, or a `PyRuntimeError`
if the operation fails.
"""
def iter_messages(self) -> collections.abc.AsyncIterator[ReceiveMessage]:
r"""
Asynchronously iterate over `ReceiveMessage`s.
Returns an async iterator that raises `StopAsyncIteration` when no more messages are available
or a `PyRuntimeError` on failure.
Note: This method does not currently support `AutoCommit.After`.
For `AutoCommit.IntervalOrAfter(datetime.timedelta, AutoCommitAfter)`,
only the interval part is applied; the `after` mode is ignored.
Use `consume_messages()` if you need commit-after-processing semantics.
"""
def consume_messages(
self,
callback: collections.abc.Callable[
[ReceiveMessage], collections.abc.Awaitable[None]
],
shutdown_event: typing.Optional[asyncio.Event],
) -> collections.abc.Awaitable[None]:
r"""
Consumes messages continuously using a callback function and an optional `asyncio.Event` for signaling shutdown.
Returns an awaitable that completes when shutdown is signaled or a PyRuntimeError on failure.
"""
class PollingStrategy:
class Offset(PollingStrategy):
__match_args__ = ("value",)
@property
def value(self) -> builtins.int: ...
def __new__(cls, value: builtins.int) -> PollingStrategy.Offset: ...
class Timestamp(PollingStrategy):
__match_args__ = ("value",)
@property
def value(self) -> builtins.int: ...
def __new__(cls, value: builtins.int) -> PollingStrategy.Timestamp: ...
class First(PollingStrategy):
__match_args__ = ((),)
def __new__(cls) -> PollingStrategy.First: ...
class Last(PollingStrategy):
__match_args__ = ((),)
def __new__(cls) -> PollingStrategy.Last: ...
class Next(PollingStrategy):
__match_args__ = ((),)
def __new__(cls) -> PollingStrategy.Next: ...
...
class ReceiveMessage:
r"""
A Python class representing a received message.
This class wraps a Rust message, allowing for access to its payload and offset from Python.
"""
def payload(self) -> bytes:
r"""
Retrieves the payload of the received message.
The payload is returned as a Python bytes object.
"""
def offset(self) -> builtins.int:
r"""
Retrieves the offset of the received message.
The offset represents the position of the message within its topic.
"""
def timestamp(self) -> builtins.int:
r"""
Retrieves the timestamp of the received message.
The timestamp represents the time of the message within its topic.
"""
def id(self) -> builtins.int:
r"""
Retrieves the id of the received message.
The id represents unique identifier of the message within its topic.
"""
def checksum(self) -> builtins.int:
r"""
Retrieves the checksum of the received message.
The checksum represents the integrity of the message within its topic.
"""
def length(self) -> builtins.int:
r"""
Retrieves the length of the received message.
The length represents the length of the payload.
"""
def partition_id(self) -> builtins.int:
r"""
Retrieves the partition this message belongs to.
"""
class SendMessage:
r"""
A Python class representing a message to be sent.
This class wraps a Rust message meant for sending, facilitating
the creation of such messages from Python and their subsequent use in Rust.
"""
def __new__(cls, data: builtins.str | bytes) -> SendMessage:
r"""
Constructs a new `SendMessage` instance from a string or bytes.
This method allows for the creation of a `SendMessage` instance
directly from Python using the provided string or bytes data.
"""
class StreamDetails:
@property
def id(self) -> builtins.int: ...
@property
def name(self) -> builtins.str: ...
@property
def messages_count(self) -> builtins.int: ...
@property
def topics_count(self) -> builtins.int: ...
class TopicDetails:
@property
def id(self) -> builtins.int: ...
@property
def name(self) -> builtins.str: ...
@property
def messages_count(self) -> builtins.int: ...
@property
def partitions_count(self) -> builtins.int: ...