Skip to content

Commit

Permalink
Add in-progress tutorial to how-to section (#1859)
Browse files Browse the repository at this point in the history
* Add in-progress tutorial to how-to section

* Update pre-commit config

* chore: fix precommit

---------

Co-authored-by: Nikita Pastukhov <[email protected]>
  • Loading branch information
sheldygg and Lancetnik authored Oct 20, 2024
1 parent 975d182 commit 7c5cc6c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ repos:
stages: [pre-commit, pre-merge-commit, manual]
entry: "scripts/lint-pre-commit.sh"
language: python
language_version: python3.10
types: [python]
require_serial: true
verbose: true
Expand All @@ -49,7 +48,6 @@ repos:
name: Static analysis
entry: "scripts/static-pre-commit.sh"
language: python
language_version: python3.10
types: [python]
require_serial: true
verbose: true
Expand All @@ -60,7 +58,6 @@ repos:
name: Build docs
entry: "scripts/build-docs-pre-commit.sh"
language: python
language_version: python3.10
files: ^docs
require_serial: true
verbose: true
Expand Down
1 change: 1 addition & 0 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ search:
- [Message Information](nats/message.md)
- [How-To](howto/nats/index.md)
- [DynaConf](howto/nats/dynaconf.md)
- [In-Progess](howto/nats/in-progress.md)
- [Redis](redis/index.md)
- [Pub/Sub](redis/pubsub/index.md)
- [Subscription](redis/pubsub/subscription.md)
Expand Down
39 changes: 39 additions & 0 deletions docs/docs/en/howto/nats/in-progress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 10
---

# In-Progress sender

Nats Jetstream uses the at least once principle, so the message will be delivered until it receives the ACK status (even if your handler takes a long time to process the message), so you can extend the message processing status with a request

??? example "Full Example"
```python linenums="1"
import asyncio

from faststream import Depends, FastStream
from faststream.nats import NatsBroker, NatsMessage

broker = NatsBroker()
app = FastStream(broker)

async def progress_sender(message: NatsMessage):
async def in_progress_task():
while True:
await asyncio.sleep(10.0)
await message.in_progress()

task = asyncio.create_task(in_progress_task())
yield
task.cancel()

@broker.subscriber("test", dependencies=[Depends(progress_sender)])
async def handler():
await asyncio.sleep(20.0)

```
1 change: 1 addition & 0 deletions docs/docs/navigation_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ search:
- [Message Information](nats/message.md)
- [How-To](howto/nats/index.md)
- [DynaConf](howto/nats/dynaconf.md)
- [In-Progess](howto/nats/in-progress.md)
- [Redis](redis/index.md)
- [Pub/Sub](redis/pubsub/index.md)
- [Subscription](redis/pubsub/subscription.md)
Expand Down

0 comments on commit 7c5cc6c

Please sign in to comment.