Skip to content

Commit a907ded

Browse files
Update documentation (#977)
Co-authored-by: daniil-quix <[email protected]>
1 parent a5cbb88 commit a907ded

File tree

4 files changed

+250
-79
lines changed

4 files changed

+250
-79
lines changed

docs/api-reference/application.md

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Application()
1111
```
1212

13-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L87)
13+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L89)
1414

1515
The main Application class.
1616

@@ -87,7 +87,7 @@ def __init__(broker_address: Optional[Union[str, ConnectionConfig]] = None,
8787
max_partition_buffer_size: int = 10000)
8888
```
8989

90-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L125)
90+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L127)
9191

9292

9393
<br>
@@ -188,7 +188,7 @@ instead of the default one.
188188
def Quix(cls, *args, **kwargs)
189189
```
190190

191-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L390)
191+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L397)
192192

193193
RAISES EXCEPTION: DEPRECATED.
194194

@@ -211,7 +211,7 @@ def topic(name: str,
211211
timestamp_extractor: Optional[TimestampExtractor] = None) -> Topic
212212
```
213213

214-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L422)
214+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L429)
215215

216216
Create a topic definition.
217217

@@ -293,7 +293,7 @@ def dataframe(topic: Optional[Topic] = None,
293293
source: Optional[BaseSource] = None) -> StreamingDataFrame
294294
```
295295

296-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L502)
296+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L509)
297297

298298
A simple helper method that generates a `StreamingDataFrame`, which is used
299299

@@ -349,7 +349,7 @@ to be used as an input topic.
349349
def stop(fail: bool = False)
350350
```
351351

352-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L558)
352+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L565)
353353

354354
Stop the internal poll loop and the message processing.
355355

@@ -373,12 +373,13 @@ to unhandled exception, and it shouldn't commit the current checkpoint.
373373
#### Application.get\_producer
374374

375375
```python
376-
def get_producer() -> Producer
376+
def get_producer(transactional: bool = False) -> Producer
377377
```
378378

379-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L603)
379+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L610)
380380

381381
Create and return a pre-configured Producer instance.
382+
382383
The Producer is initialized with params passed to Application.
383384

384385
It's useful for producing data to Kafka outside the standard Application processing flow,
@@ -387,6 +388,15 @@ Using this within the StreamingDataFrame functions is not recommended, as it cre
387388
instance each time, which is not optimized for repeated use in a streaming pipeline.
388389

389390

391+
<br>
392+
***Arguments:***
393+
394+
- `transactional`: if True, the producer will be configured to use transactions
395+
regardless of Application's processing guarantee setting. But the responsibility
396+
for beginning and committing the transaction is on the user.
397+
Default - False.
398+
399+
390400
<br>
391401
***Example Snippet:***
392402

@@ -411,7 +421,7 @@ with app.get_producer() as producer:
411421
def get_consumer(auto_commit_enable: bool = True) -> Consumer
412422
```
413423

414-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L658)
424+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L678)
415425

416426
Create and return a pre-configured Consumer instance.
417427

@@ -468,7 +478,7 @@ with app.get_consumer() as consumer:
468478
def clear_state()
469479
```
470480

471-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L707)
481+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L727)
472482

473483
Clear the state of the application.
474484

@@ -482,7 +492,7 @@ Clear the state of the application.
482492
def add_source(source: BaseSource, topic: Optional[Topic] = None) -> Topic
483493
```
484494

485-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L713)
495+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L733)
486496

487497
Add a source to the application.
488498

@@ -513,7 +523,7 @@ def run(dataframe: Optional[StreamingDataFrame] = None,
513523
metadata: bool = False) -> list[dict]
514524
```
515525

516-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L746)
526+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L766)
517527

518528
Start processing data from Kafka using provided `StreamingDataFrame`
519529

@@ -589,7 +599,7 @@ Default - `False`.
589599
class ApplicationConfig(BaseSettings)
590600
```
591601

592-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1104)
602+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1124)
593603

594604
Immutable object holding the application configuration
595605

@@ -612,7 +622,7 @@ def settings_customise_sources(
612622
) -> Tuple[PydanticBaseSettingsSource, ...]
613623
```
614624

615-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1140)
625+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1160)
616626

617627
Included to ignore reading/setting values from the environment
618628

@@ -626,7 +636,23 @@ Included to ignore reading/setting values from the environment
626636
def copy(**kwargs) -> "ApplicationConfig"
627637
```
628638

629-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1153)
639+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1173)
630640

631641
Update the application config and return a copy
632642

643+
<a id="quixstreams.app.resolve_transactional_id"></a>
644+
645+
<br><br>
646+
647+
#### resolve\_transactional\_id
648+
649+
```python
650+
def resolve_transactional_id(transactional_id: Optional[str],
651+
prefix: str) -> str
652+
```
653+
654+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1195)
655+
656+
Utility function to resolve the transactional.id based
657+
on existing config and provided prefix.
658+

docs/api-reference/kafka.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ or a ConnectionConfig object if authentication is required.
4848
will be passed to `confluent_kafka.Producer` as is.
4949
Note: values passed as arguments override values in `extra_config`.
5050
- `flush_timeout`: The time the producer is waiting for all messages to be delivered.
51+
- `transactional`: if `True`, the Producer will go into the transactional
52+
mode where you can use the Kafka Transactions API.
53+
By default, the "transactional.id" is generated randomly on init.
54+
To customize it, pass it via the `extra_config` parameter.
5155

5256
<a id="quixstreams.kafka.producer.Producer.produce"></a>
5357

@@ -67,7 +71,7 @@ def produce(topic: str,
6771
on_delivery: Optional[DeliveryCallback] = None)
6872
```
6973

70-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/kafka/producer.py#L117)
74+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/kafka/producer.py#L121)
7175

7276
Produce a message to a topic.
7377

@@ -102,7 +106,7 @@ for the produced message.
102106
def poll(timeout: float = 0)
103107
```
104108

105-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/kafka/producer.py#L178)
109+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/kafka/producer.py#L182)
106110

107111
Polls the producer for events and calls `on_delivery` callbacks.
108112

@@ -123,7 +127,7 @@ Polls the producer for events and calls `on_delivery` callbacks.
123127
def flush(timeout: Optional[float] = None) -> int
124128
```
125129

126-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/kafka/producer.py#L213)
130+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/kafka/producer.py#L217)
127131

128132
Wait for all messages in the Producer queue to be delivered.
129133

0 commit comments

Comments
 (0)